Android: Linear Layout and weight
来源:互联网 发布:js数组添加元素 push 编辑:程序博客网 时间:2024/04/24 20:34
使用weight需要记住三点:
结果:
- 子元素的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
0 0
- Android: Linear Layout and weight
- android layout-weight属性
- Android:layout—-weight属性
- Android——Layout Weight
- Android线性布局(Linear Layout)
- Android API Guides---Linear Layout
- Android线性布局(Linear Layout)
- android 中layout weight的作用
- Android 错误集合之Layout weight不起作用
- AndroidのUI布局之layout weight
- Android基础:xml布局中的Layout Weight
- Linear Layout
- Linear Layout
- Linear Layout
- Android布局之一——Linear Layout
- Android UI学习 - Linear Layout, RelativeLayout
- Android开发笔记之Linear Layout
- Android UI学习 - Linear Layout, RelativeLayout
- OnPaint 与OnDraw的区别
- 伪指令实现分支结构
- Android数据的存储方式 ContentProvider
- 动态页面静态化
- Oracle安装问题INS-30131解决方法
- Android: Linear Layout and weight
- the furthest distance in the world
- iOS7 企业应用"无法安装应用程序 因为证书无效"的解决方案
- 老鼠走迷宫
- 网站页面静态化方案
- git branch
- 重写equals()与hashCode()
- 小小_关于IOS库文件的问题
- IOS 企业版发布后,用户通过sarafi浏览器安装无效的解决方案