2011-02-17 85 views
0

我有一個有兩個嵌套RelativeLayouts的RelativeLayout。我希望第一個RL保持在第一位,第二個可滾動,但這不起作用。Android RelativeLayout問題

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout 
    android:id="@+id/relativeTop" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <!--Buttons--> 
    </RelativeLayout> 
    <ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <!--Lots of nested RelatiLayouts with Views--> 
    </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 
+0

代碼插入只是粘貼它,標記代碼並按下上面的「{}」按鈕 – WarrenFaith 2011-02-17 20:58:22

回答

1

有一個XML屬性,你需要知道該android:layout_below

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout 
    android:id="@+id/relativeTop" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <!--Buttons--> 
    </RelativeLayout> 
    <ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/relativeTop"> <!-- here it goes! --> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <!--Lots of nested RelatiLayouts with Views--> 
    </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

另一種方法是對的LinearLayout佈局有偉大的工程,因爲它可以「分」你的佈局分成兩個部分,..