我在使用這段代碼困難:安卓:如何申請的LayoutParams我的RelativeLayout
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RelativeLayout layout = (RelativeLayout)findViewById(R.id.RelativeLayout1);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
我有我的RelativeLayout1在這樣的XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="60dp"
android:paddingTop="53dp" >
但在我申請的時候scrollview,RelativeLayout1的fill_parent不能像它不是scrollview的子節點時那樣工作。當它不是一個孩子時(即我完全移除滾動視圖),那麼相對佈局覆蓋整個屏幕,因爲我喜歡它。但是當我把它放在scrollview中時,即使我使用了fill_parent,它也只能到達相關佈局中的最後一個元素(一個按鈕)。
所以我試圖通過編程來查看它是否有所作爲,但我似乎無法弄清楚如何將我的params變量應用到我的佈局中的第一位代碼。如果您有任何其他想法,請讓我知道。
謝謝!這看起來不錯。 – capcom 2012-07-31 13:20:03