Android ApiDemos示例解析(149):Views->Layouts->LinearLayout->9. Layout Weight
2012-09-03 06:55
441 查看
本例介绍了layout_weight 的用法,layout_weight 用法前面已介绍过:如Android
ApiDemos示例解析(147):Views->Layouts->LinearLayout->7. Fill Parent
和 Android
ApiDemos示例解析(143):Views->Layouts->LinearLayout->3. Vertical (Padded)。
本例使用了一个 ListView 和 Button ,将ListView 的weight 设为1, 而 Button 没有权重(为0) ,因此ListView 将占据所有除Button之外的所有空间:
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<ListView android:id=”@+id/list”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_weight=”1.0″ />
<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_9_button” />
</LinearLayout>
ApiDemos示例解析(147):Views->Layouts->LinearLayout->7. Fill Parent
和 Android
ApiDemos示例解析(143):Views->Layouts->LinearLayout->3. Vertical (Padded)。
本例使用了一个 ListView 和 Button ,将ListView 的weight 设为1, 而 Button 没有权重(为0) ,因此ListView 将占据所有除Button之外的所有空间:
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<ListView android:id=”@+id/list”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_weight=”1.0″ />
<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/linear_layout_9_button” />
</LinearLayout>
相关文章推荐
- Android ApiDemos示例解析(143):Views->Layouts->LinearLayout->3. Vertical (Padded)
- Android ApiDemos示例解析(142):Views->Layouts->LinearLayout->2. Vertical (Fill Screen)
- Android ApiDemos示例解析(150):Views->Layouts->LinearLayout->10. Background Image
- Android ApiDemos示例解析(141):Views->Layouts->LinearLayout->1. Vertical
- Android ApiDemos示例解析(144):Views->Layouts->LinearLayout->4. Horizontal
- Android ApiDemos示例解析(148):Views->Layouts->LinearLayout->8. Gravity
- Android ApiDemos示例解析(146):Views->Layouts->LinearLayout->6. Uniform Size
- Android ApiDemos示例解析(147):Views->Layouts->LinearLayout->7. Fill Parent
- Android ApiDemos示例解析(145):Views->Layouts->LinearLayout->5.Simple Form
- Android ApiDemos示例解析(152):Views->Layouts->RelativeLayout->2.Simple Form
- Android ApiDemos示例解析(157):Views->Layouts->TableLayout->02. Empty Cells
- Android ApiDemos示例解析(161):Views->Layouts->TableLayout->06. More Spanning and Stretchable
- Android ApiDemos示例解析(156):Views->Layouts->TableLayout->01. Basic
- Android ApiDemos示例解析(158):Views->Layouts->TableLayout->03.Long Content
- Android ApiDemos示例解析(164):Views->Layouts->TableLayout->09. Toggle Shrink
- Android ApiDemos示例解析(151):Views->Layouts->RelativeLayout->1. Vertical
- Android ApiDemos示例解析(159):Views->Layouts->TableLayout->04.Stretchable
- Android ApiDemos示例解析(160):Views->Layouts->TableLayout->05. Spanning and Stretchable
- Android ApiDemos示例解析(165):Views->Layouts->TableLayout->10. Simple Form
- Android ApiDemos示例解析(162):Views->Layouts->TableLayout->07. Column Collapse