<LinearLayout android:id="@+id/lnLayoutBottom" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1" android:enabled="false"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1" android:enabled="false"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_weight="1" android:enabled="false"/> </LinearLayout>
如果 五个Button的android:layout_width 属性 设置为 "fill_parent" 则 在android:layout_weight 的影响下, 起五个button的长度将相等,
如果设置为 wrap_content , 则其长度不等。。。。。
本文探讨了在Android布局中使用LinearLayout时,如何通过android:layout_weight属性来调整Button组件的宽度分配。当Button的宽度设置为fill_parent时,所有Button的宽度相等;而设置为wrap_content时,各Button的宽度依据内容自动调整。
240

被折叠的 条评论
为什么被折叠?



