android UI设计 layout_weight解析
2015-07-31 23:02
615 查看
[code]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Detail" style="?android:listSeparatorTextViewStyle"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Wed Oct 17 15:49:50 EDT 2012"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="solved"/> </LinearLayout> </LinearLayout>
效果图:
如果把android:layout_weight=”1”改为android:layout_weight=”0”
[code]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Detail" style="?android:listSeparatorTextViewStyle"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="Wed Oct 17 15:49:50 EDT 2012"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:text="solved"/> </LinearLayout> </LinearLayout>
效果图:
让LinearLayout只考虑android:layout_weight来分配空间,令android:layout_weight=”0”,这时候控件等分。
而android:layout_weight=”1”,会结合android:layout_width和android:layout_weight来划分控件,所以第一张图Button内容多,区域也就占得多。
相关文章推荐
- hdu 5312 Sequence(数学)
- Can you answer these queries?---hdu4027
- NGUI(三)背包系统页面
- iOS学习(UIImageView)
- ubuntu下vagrant up经常出现Failed to upload a file to the guest VM via SCP due to a permissions error.最终解决
- hdu 5297 Y sequence(容斥)
- 黑马程序员------API(String类,StringBuffer,StringBuilder及基本数据类型包装类)
- Entityframework~Fluent Api配置数据模型与数据库结构关系
- mysql启动错误:Starting MySQL.. ERROR! The server quit without updating PID file错误
- 递归和循环---从EasyUI Tree 发现自己的硬伤
- uva11235 Frequent values(线段树区间合并)
- LTView 自定义视图 UIAlertView
- EasyUi 新组件 switchbutton 根据状态切换显示内容
- Android API Guides 阅读笔记(9)----Bound Service
- UVA1152-4 Values whose Sum is 0
- UIViewController(视图控制器)下的View切换
- UVA1605-Building for UN
- 仿Uber主界面布局,框架简单实现
- iOS-01-UILabel
- PcDuino初学分享