这个属性用于控制控件的大小,当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!

更多相关文章

  1. 【Android】android 常见性能优化笔记
  2. android顶部(toolbar)搜索框实现
  3. Android中的表格布局详解
  4. Android中给系统控件添加配置的自定义属性
  5. android 对listview数据的增删改查
  6. ViewPager 一屏显示多个效果
  7. 菜鸟学android---ListView和checkBox组合常见问题
  8. Android(安卓)Studio中Button等控件的Text属性英文默认大写的解
  9. Android(安卓)OpenGL添加光照和材料属性

随机推荐

  1. Android(安卓)6种快速开发框架
  2. Android(安卓)Camera Hal 的初步实现1
  3. php脚本生成google play url的下载链接,下
  4. Android之Handle的使用[二]
  5. Android(安卓)中Uri的用法汇总
  6. Android(安卓)ril原生代码(C/C++)和java代码部
  7. Android横竖屏切换正确实现方式
  8. Android中TextView的某一关键字高亮显示
  9. Android任务和返回栈完全解析
  10. Android(安卓)下使用tcpdump 抓包工具