LinearLayout中的weight属性的计算
来源:互联网 发布:阿里云域名过户步骤 编辑:程序博客网 时间:2024/06/05 15:57
最终宽度 = 控件原来宽度 + 控件在父控件剩余空间所占的百分比(也就是weight的值)
以下两个例子进行说明:
条件:假设父控件宽度为L
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="1"/> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="2"/></LinearLayout>
因为Button1和Button2的layout_width=match_parent, 所以原有宽度为L,而父控件的剩余 宽度就是L - 2L(父控件的宽度 - Button1和Button2的原有宽度);
Button1的宽度: 实际宽度 = L + (L-2L) * 1/3 = (2/3)L;
Button2的宽度: 实际宽度 = L + (L-2L) * 2/3 = (1/3)L;
match_parent可理解为当前控件的宽度=父控件的宽度,而wrap_content可理解为当前控件的宽度=0
height的计算和width一样,不过需要注意设置height是LinearLayout的orientation属性的值为vertical
0 0
- LinearLayout中的weight属性的计算
- LinearLayout中的weight属性的计算
- LinearLayout 中的 weight 属性
- 关于LinearLayout中的weight的属性
- 浅析LinearLayout的weight属性
- LinearLayout的weight(权重属性)
- LinearLayout内的权重属性 weight
- Android-LinearLayout的weight属性分配原则分析
- LinearLayout之weight属性
- LinearLayout布局中的weight的理解
- LinearLayout的weight
- Android中LinearLayout布局的Weight属性详解
- LinearLayout的两个关键属性(layout_gravity&weight)
- LinearLayout中weight的学习
- android LinearLayout的weight问题
- LinearLayout的weight(权值)详解
- LinearLayout中的layout_weight属性 的使用
- LinearLayout中的属性baselineAligned的使用
- Android ViewStub归纳
- Git的常用撤销技巧
- 关于Jquery中json的使用
- 函数与程序结构 例题
- Fragment入门
- LinearLayout中的weight属性的计算
- java 用http发post请求
- java多线程编程
- hxy系列1-Python基础
- verilog入门经验(四) 经验总结
- mycat全局序列号
- 微信小程序 (应用号)开发(教程)文档,内附开发工具及工具使用方法
- 欧洲央行德拉吉说低利率未来必然获得高利率
- python 将文字转为图片Logo