2009-10-08 57 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

相关问题