【发布时间】:2014-05-29 09:42:41
【问题描述】:
我在屏幕顶部有一些ImageButton,在它们下方有一个Scrollview。
(XML 是RelativeLayout)
我想调整Scrollview 的大小,它在哪里。
我使用此代码:
scrollview.setLayoutParams(new RelativeLayout.LayoutParams(200,200)) ;
Scrollview 调整大小,但它移动到屏幕顶部。
我想调整ScrollView 的大小。
我不希望它移动到顶部。
我使用什么代码?
完整的 XML 和 JavaCode 在这里:
p30droid.com/Thread-تغییر-اندازه-اسکرول-ویو-و-imagebutton-و-button
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout1"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/button11"
android:layout_width="140dp"
android:layout_height="65dp"
android:text="تغییر سایز" />
<ImageButton
android:id="@+id/imageButton8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/imageButton9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout2"
android:layout_above="@+id/linearLayout3"
android:layout_centerHorizontal="true" >
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
【问题讨论】:
-
看不到您的 XML 文件
标签: android resize scrollview