Layout 中有写法如下:
layout_height="0dip" 或者 layout_width="0dip"
这里的意思是不是用具体的数值来计算高度或者宽度,而是和layout_weight 一起来使用的。经常会有这样的写法: 同一个LinearLayout (假设是横向的) 中 有几个view ,但是都不指定其具体的宽度,而是使用 layout_weight 参数来指定这几个view所占的比例。每个view所占的宽度的比例是自己的layout_weight 值和总的layout_weight的总和的比值。
例如:
<LinearLayoutandroid:id="@+id/remove_account_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:drawable/bottom_bar">
<View
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Buttonandroid:id="@+id/remove_account_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginTop="5dip"
android:text="@string/remove_account_label" />
<View
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
这几个View宽度的的比例便是1:2:1
转自:http://blog.csdn.net/vallay_star/article/details/7013169