Linearlayout中weight属性的计算公式:
最终宽度 = 控件原来宽度 + 控件在父控件剩余空间所占的百分比(也就是weight的值)
以下两个例子进行说明:
条件:假设父控件宽度为L
例1.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"