我正在寫一個Android應用程序有它包含的LinearLayout滾動型:改變滾動視圖的位置在Android的
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity=top"
android:layout_marginTop="240dip"
android:layout_marginRight="0dip"
android:layout_marginBottom="60dip">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/centerlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:layout_marginRight="20dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="120dip">
正如你看到的,滾動型的保證金頂部是「240dip」。我希望能夠在我的Java代碼中進行更改。我試過這個:
ScrollView scrollView=(ScrollView)findViewById(R.id.ScrollView01);
LayoutParams params=scrollView.getLayoutParams();
但我不能這樣做:params.top = 100;你能幫我怎麼做嗎?