layout_weight 属性分析
2012-09-01 17:43
330 查看
以如下布局为例:
可以看作:
1、全为wrap_content 时 layout_weight月接近0,越接近wrap_content(占比例越小)
当layout_weight=0 时 ,width 为 wrap_content; 如果全部layout_weight =0 ,全部为wrap_content,而并不会和全为其他非零值时一样平均分割;
2、全为fill_parent 时layout_weight越接近0,越接近fill_parent(占比例越大)
有多个layout_weight为0时,第一个为0的充满父控件
3、layout_weight 为负数则不在视图内
<?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"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:layout_width="fill_parent" android:text="@string/bt_show1" android:textColor="#ff0000" android:layout_height="wrap_content" android:layout_weight="10.0" /> <Button android:layout_width="fill_parent" android:text="@string/bt_show2" android:textColor="#ff0000" android:layout_height="wrap_content" android:layout_weight="1.0" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:text="@string/bt_show3" android:textColor="#ff0000" android:layout_height="wrap_content" android:layout_weight="10.0" /> <Button android:layout_width="wrap_content" android:text="@string/bt_show4" android:textColor="#ff0000" android:layout_height="wrap_content" android:layout_weight="1.0" /> </LinearLayout> </LinearLayout>
可以看作:
1、全为wrap_content 时 layout_weight月接近0,越接近wrap_content(占比例越小)
当layout_weight=0 时 ,width 为 wrap_content; 如果全部layout_weight =0 ,全部为wrap_content,而并不会和全为其他非零值时一样平均分割;
2、全为fill_parent 时layout_weight越接近0,越接近fill_parent(占比例越大)
有多个layout_weight为0时,第一个为0的充满父控件
3、layout_weight 为负数则不在视图内
相关文章推荐
- android中layout_weight属性分析
- layout_weight属性分析
- android:layout_weight属性分析
- 详解 Android Views 元素的 layout_weight 属性
- 安卓按比例布局,layout_weight用法、合用weightSum属性和layout_weight属性
- android:layout_weight属性详解
- Android手机开发:android:layout_weight属性的使用
- 安卓中linearLayout下android_layout.weight的属性的详细介绍
- Android Layout_weight 属性
- 安卓layout_weight属性解析
- 不可忽视的布局属性layout_weight,彻底纠正网上很多对于该属性的片面理解
- 关于Android相对布局中的四个属性:layout_alignTop,layout_alignBottom,layout_above,layout_below的分析
- LinearLayout布局的layout_weight属性
- 不可忽视的布局属性layout_weight,彻底纠正网上很多对于该属性的片面理解
- Layout_weight属性
- 关于Android UI组件LinearLayout属性layout_weight与layout_width/height的问题
- 日积月累:LinearLayout的andrid:layout_weight属性的使用详解
- layout_weight及常见属性解析
- 神奇的layout_weight属性