这个属性很重要,使用的时候需要注意:

1.使用过程中如果觉得奇怪,需要检查下控件的layout_height和layout_width是否需要设置为fill_parent

2.两个同一层次的控件使用这个属性的时候,设置的数字大的,所占的比例反而小,例如android:layout_weight = “3”

android:layout_weight = “1”。显示出来的效果是1:3 我也不知道为什么是这样。希望有知道的能知会一下。

3.如果使用LinearLayout垂直摆放3个控件。上下两个控件不设置android:layout_weight。中间的控件设置为android:layout_weight = “1” 则,意思是:除了上下两个控件各自显示各自的大小,剩下的屏幕部分都被中间控件填充

假设中间是一个不确定大小的ListView,则底部的控件不会被遮盖

比如:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical"    android:background="#ffffff"><TextView     android:layout_width="fill_parent"    android:layout_height="50dip"    android:gravity="center"android:textSize="20dip"android:textColor="#ffffff"    android:background="#33b5e5"    android:text="详细记录"/><ListView android:id="@+id/sdc_lv_call_detail" android:layout_width="fill_parent" android:layout_height="wrap_content"android:cacheColorHint="#00000000"android:listSelector="@android:color/transparent"android:background="#ffffff"android:layout_weight="1"android:divider="#cccccc"android:dividerHeight="0.5dip"/>  <LinearLayout     android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:orientation="vertical"    >                   <!--  底部的控件  -->       </LinearLayout></LinearLayout>

更多相关文章

  1. 箭头函数的基础使用
  2. NPM 和webpack 的基础使用
  3. Python list sort方法的具体使用
  4. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  5. [置顶] [Android基础]Android中SharedPreferences的使用
  6. android 使用Intent传递数据之返回结果
  7. Android(安卓)Layout XML属性
  8. Android(安卓)数据存储(二) 文件的使用
  9. Android(安卓)动态设置TextView的drawableLeft等属性

随机推荐

  1. 第15章、布局Layouts之TableLayout表格布
  2. Android 切换主题以及换肤的实现
  3. Android(安卓)Studio中的Project和Module
  4. android例子分析-1
  5. Android检索图像
  6. Android 之 Handler的分析
  7. Android中V4包下的Fragment使用
  8. android:imeOptions属性详解(Enter功能)
  9. Instant Run详解
  10. android mediaplayer 播放流媒体 m3u8