LinearLayout中的layout_weight属性
来源:互联网 发布:淘宝网上药店哪家正规 编辑:程序博客网 时间:2024/05/21 09:03
LinearLayout中的layout_weight属性
布局LinearLayout代码
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <Button
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="Button1"
- android:background="#008000"
- android:layout_weight="0"
- />
- <Button
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="Button2"
- android:background="#FFFF00"
- android:layout_weight="0"
- />
- </LinearLayout>
layout_weight属性如果没有设置,则默认为0.
按钮1:button1,绿色
按钮2:button2,黄色
下面以按钮1和按钮2的weight属性(layout_weight)的变化,分别进行记录。
这里测试的是垂直布局android:orientation="vertical",所以针对组件的android:layout_height属性;如果测试的水平布局,则需针对组件的android:layout_width属性。
(一) android:layout_height="fill_parent"
button1(weight=0) button2(weight=0) button1(weight=0) button2(weight=1)button1(weight=1) button2(weight=1)
button1占1/2,button2占1/2
button1(weight=1) button2(weight=2)
button1占2/3,button2占1/3
button1(weight=1) button2(weight=9)
button1占9/10,button2占1/10
button1(weight=1) button2(weight=30)
button1占30/31,button2占1/31
(二) android:layout_height="wrap_content"
button1(weight=0) button2(weight=0)
button1(weight=0) button2(weight=1)button1(weight=1) button2(weight=1)
button1占1/2,button2占1/2
button1(weight=1) button2(weight=2)
button1占1/3,button2占2/3
button1(weight=1) button2(weight=9)
button1(weight=1) button2(weight=30)
通过以上实验可知:
(一) android:layout_height="fill_parent"
(二) android:layout_height="wrap_content"
在(一)、(二)2种情况在相同的weight属性下呈现出正好相反的情况。
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性
- LinearLayout中的layout_weight属性详解
- LinearLayout中的layout_weight属性 的使用
- LinearLayout中的layout_weight属性深入研究
- LinearLayout中layout_weight属性
- LinearLayout中layout_weight属性
- LinearLayout的layout_weight属性
- LinearLayout中的android:layout_weight属性的设置和使用
- android开发中LinearLayout中的Layout_weight属性的理解
- LinearLayout layout_weight属性的妙用
- LinearLayout布局的layout_weight属性
- Android 笔记 linearlayout 属性 layout_weight
- LinearLayout中的layout_weight的使用
- 解决IE6不支持li:hover鼠标经过的效果
- 【Android】数据库处理
- IQFLEX/IQVIEW无线网络测试仪
- Telematics
- JDBC连接数据库
- LinearLayout中的layout_weight属性
- adb install 流程
- ASP.net中太长的数据缩略显示
- netlink socket编程之why & how
- 漫谈C语言及如何学习C语言(一)为什么要学习C语言?
- 学习java多线程的笔记4--传智播客_张孝祥_空中网挑选实习生的面试题(来源于视频)
- SLG
- php读写excel类函数
- 自定义UITabBar 背景图片