Android属性系列之layout_weight
来源:互联网 发布:2017淘宝上下架时间 编辑:程序博客网 时间:2024/05/10 02:54
对自己现在所了解的layout_weight属性进行记录,不求全面,只求正确!
layout_weight意为"权重",我的理解就是给组件设置一个显示大小的比例。
layout_weight设置一个值,会出现两种情况。
第一种:当组件的“layout_width”属性为“fill_parent”时,值越小,组件越大。
第二种:当组件的“layout_width”属性为“wrap_content”时,值越大,组件越大。
第一种情况:
Xml代码
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
<Button
android:id="@+id/btn_save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="保存"
/>
<Button
android:id="@+id/btn_return"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="返回"
/>
</LinearLayout>
在这里"保存"按钮的Layout_weight=1,"返回"按钮的Layout_weight=4,layout_width="fill_parent"时, 运行效果为:
第二种情况:
Xml代码
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="保存"
/>
<Button
android:id="@+id/btn_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="返回"
/>
</LinearLayout>
在这里"保存"按钮的Layout_weight=1,"返回"按钮的Layout_weight=4,layout_width="wrap_content"时,运行效果为:
以上为本人对已知情况的总结,如有不对或总结不足,望指教!
作者“背着行囊独自前行....”
- Android属性系列之layout_weight
- android之layout_weight属性
- Android布局之Layout_weight属性解析
- Android开发之layout_weight属性的应用
- android属性之layout_weight深入研究
- Android百分比布局之layout_weight属性
- android---android:layout_weight属性
- android layout_weight 属性
- android:layout_weight属性详解
- Android layout_weight属性
- android:layout_weight属性详解
- android:layout_weight属性探讨
- android:layout_weight属性详解
- Android layout_weight属性备忘
- android:layout_weight属性详解
- android:layout_weight属性讲解
- Android layout_weight属性
- android:layout_weight属性详解
- lvs+keepalive 比较详细的安装配置文档
- Unity3d动态数据管理(1) Export AssetBundles
- MFC对话框添加状态栏
- 下班的时候在电梯里碰见个妹子,问这层楼是哪个部门的。我答技术部吧。她惊异:技术部也这么晚下班?妹子,你听说过科比和程序员的故事么?
- 关于编译为ko的一些宏定义
- Android属性系列之layout_weight
- 编译CLCascade提示Undefined symbols for architecture armv7s的解决办法
- S5PV210(TQ210)学习笔记——按键驱动程序
- C语言项目--教师信息/学生成绩管理系统
- 关于Linux系统中文件系统路径的理解
- 正则表达式实例
- Extjs4---Cannot read property 'addCls' of null
- strdup与strcpy
- processing 程序1