Android: Linear Layout and weight
2014-04-10 16:20
411 查看
使用weight需要记住三点:
子元素的android:layout_width都要设为 “0dp”
父元素的android:weightSum 设为子元素的weight之和(可选项,会默认生成)
子元素的android:layout_weight的设置遵照android:weightSum按比例分配
例子:
结果:
翻译源自:
http://stackoverflow.com/questions/2698817/linear-layout-and-weight-in-android
子元素的android:layout_width都要设为 “0dp”
父元素的android:weightSum 设为子元素的weight之和(可选项,会默认生成)
子元素的android:layout_weight的设置遵照android:weightSum按比例分配
例子:
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LinearLayout>
结果:
翻译源自:
http://stackoverflow.com/questions/2698817/linear-layout-and-weight-in-android
相关文章推荐
- 对android LinearLayout中layout_weight属性使用初探
- Android 布局之LinearLayout 子控件weight权重的作用详析
- Android:深度探究线性布局LinearLayout中权重(layout_weight)属性
- android布局之LinearLayout, layout_weight
- Android LinearLayout的android:layout_weight属性
- 摘抄一篇文章android中LinearLayout中layout_weight详解
- Android 布局之LinearLayout 子控件weight权重的作用详析
- 对android LinearLayout中layout_weight属性使用
- Android 布局之LinearLayout 子控件weight权重的作用详析
- Android ApiDemos示例解析(149):Views->Layouts->LinearLayout->9. Layout Weight
- Android 布局之LinearLayout 子控件weight权重的作用详析
- android之线性布局LinearLayout以及weight权重使用
- Android LinearLayout layout_weight适应屏幕布局
- Android的LinearLayout中的权重android:layout_weight
- 通过Android源码分析LinearLayout的layout_weight与weightsum对布局大小的影响
- Android 布局之LinearLayout 子控件weight权重的作用详析
- android LinearLayout代码方式实现Weight
- 关于android LinearLayout 的layout_weight
- android LinearLayout android:layout_weight 作用,固定比例
- Android UI: LinearLayout中layout_weight 属性的使用规则