android:layout_weight属性的使用
来源:互联网 发布:qq飞车指挥官改装数据 编辑:程序博客网 时间:2024/05/16 13:52
http://blog.csdn.net/hustspy1990/article/details/6725298
这个属性用于控制控件的大小,当LinearLayout布局是垂直布局的时候,它就控制高度的大小;当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">
- <TextView android:id="@+id/sample_1"
- android:background="@color/red" android:layout_weight="1"
- android:layout_width="fill_parent" android:layout_height="0dip" />
- <TextView android:id="@+id/sample_2"
- android:background="@color/black" android:layout_weight="2"
- android:layout_width="fill_parent" android:layout_height="0dip" />
- <TextView android:id="@+id/sample_3"
- android:background="@color/white" android:layout_weight="3"
- android:layout_width="fill_parent" android:layout_height="0dip" />
- <TextView android:id="@+id/sample_4"
- android:background="@color/blue" android:layout_weight="4"
- android:layout_width="fill_parent" android:layout_height="0dip" />
- </LinearLayout>
上面代码显示出来之后,sample_1:sample_2:sample_3:sample_4高度比=1:2:3:4。
很重要的一点是,高度属性要设定为0,绝对不能设定为fill_parent,不然就不会成比例了!这是在布局是垂直布局时候的情况,水平时,则定义宽度属性为0!
- android:layout_weight属性的使用
- android:layout_weight属性的使用
- Android layout_weight属性使用
- layout_weight属性的使用
- android:layout_weight属性使用注意事项
- Android layout_weight 属性使用介绍
- Android手机开发:android:layout_weight属性的使用
- Android的layout_weight属性详解
- Android的layout_weight属性释疑
- Android布局的layout_weight属性
- android Layout_weight属性的详解
- 关于layout_weight属性的使用
- android:layout_weight的使用
- LinearLayout中的android:layout_weight属性的设置和使用
- 关于android:layout_weight属性使用注意事项
- 对android LinearLayout中layout_weight属性使用
- 对android的layout_weight属性的理解
- 对android的layout_weight属性的理解
- [Android开发]Android 重要组件 之 Intent
- platform设备添加流程
- 记录下callstack信息
- WinForm应用程序框架设计之WinAction(删除数据)
- APMServ启用.htaccess伪静态重写功能,APMServ设置伪静态
- android:layout_weight属性的使用
- Request.返回值
- POJ 3126 Prime Path BFS
- sql developer无法更新数据
- 教你用VS2008/VS2010写简单C/C++语言main函数程序
- C# 中的委托和事件
- 回文字符串的测试
- windows下安装emacs收藏
- 如果分配给命令的连接位于本地挂起事务中,ExecuteNonQuery 要求命令拥有事务。命令的 Transaction 属性尚未初始化