2013-07-22 50 views

回答

4

你想用一个垂直的LinearLayout,像这样:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="3" > 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="#ff0000" > 
    </FrameLayout> 
    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="#00ff00" > 
    </FrameLayout> 
    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="#0000ff" > 
    </FrameLayout> 

</LinearLayout> 
+0

我不知道'weightSum'属性。 Upvoted :) –

0

您可以在此情况下,使用线性的布局,orientation:Vertical

尝试了这一点

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<Button 
    android:id="@+id/button2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.17" 
    android:text="Button" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="match_parent" 
    android:layout_height="114dp" 
    android:layout_weight="0.11" 
    android:text="Button" /> 

<Button 
    android:id="@+id/button3" 
    android:layout_width="334dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.17" 
    android:text="Button" /> 

</LinearLayout>