2009-10-08 19 views

回答

7

嘗試機器人:layout_weight = 「1」

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<View 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="#F00" 
    /> 
<View 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="#0F0" 
    /> 
<View 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="#00F" 
    /> 

+0

這是如何指定高度,以平均分配? – Ram 2009-10-08 10:55:08

+0

從android文檔:http://developer.android.com/guide/topics/ui/layout-objects.html在LinearLayout部分查找重量說明。 – Scott 2009-10-08 15:44:06

+1

爲每個子視圖指定android:layout_weight =「1」將直接指定佈局來平均分配高度。請參閱Scott指出的文檔。 – bhatt4982 2009-10-08 16:10:10