android layout_weight的使用
2012-12-27 19:56
288 查看
在android的布局中,有时为了适配不同的分辨率的机型,可以使用android:layout_weight这个属性。layout_weight表示所在的权重,即所描述的控件所在的百分比。
例如:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:Text="text"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.0"/>
</LinearLayout>
在上述LinearLayout布局中,layout被分成3份,TextView占其中1份(即1/3),ImageView占2份(即2/3)。
平时做一些UI布局时,可以根据实际情况使用layout_weight。
本文出自 “天外来客” 博客,请务必保留此出处http://songyuanlin.blog.51cto.com/6114055/1102446
例如:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:Text="text"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.0"/>
</LinearLayout>
在上述LinearLayout布局中,layout被分成3份,TextView占其中1份(即1/3),ImageView占2份(即2/3)。
平时做一些UI布局时,可以根据实际情况使用layout_weight。
本文出自 “天外来客” 博客,请务必保留此出处http://songyuanlin.blog.51cto.com/6114055/1102446
相关文章推荐
- Android layout_weight使用
- android:layout_weight的使用
- 在android布局中使用layout_weight的几点技巧和说明layout_weight
- Android布局中的layout_weight和weightSum属性的详解及使用
- Android 对Layout_weight属性完全解析以及使用ListView来实现表格
- TabHost和android:layout_height="0.0dip"以及android:layout_weight配合在布局中的使用
- 使用android:layout_weight属性来给view group中各个控件设置所占空间大小比重
- Android 对Layout_weight属性完全解析以及使用ListView来实现表格
- Android中layout_gravity与gravity及layout_weight的使用
- Android 对Layout_weight属性完全解析以及使用ListView来实现表格
- Android中的android:layout_weight使用详解
- 【layout_weight权重】Android 对Layout_weight属性完全解析以及使用ListView来实现表格
- 透析Android 中 权重使用及分配规则(layout_weight)
- Android 对Layout_weight属性完全解析以及使用ListView来实现表格
- android:layout_weight属性的使用
- 关于linearLayout的中 android:layout_weight 的使用
- Android布局学习四:layout_weight 的使用
- 对android LinearLayout中layout_weight属性使用初探
- 关于android:layout_weight属性使用注意事项
- Android layout_weight 属性使用介绍