Android ApiDemos示例解析(167):Views->Layouts->TableLayout->12. Cell Spanning
2012-09-16 16:43
477 查看
本例介绍使用android:layout_span 为某列指明跨多行,类似于HTML中的用法:
<TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>
<TableRow>
<TextView
android:text=”@string/table_layout_12_a”
android:background=”#FFFF0000″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_b”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_c”
android:background=”#FF0000FF”
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_d”
android:layout_span=”2″
android:gravity=”center_horizontal”
android:background=”#FF0000FF”
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_e”
android:background=”#FF00FF00″
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_f”
android:background=”#FFFF00FF”
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_g”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_h”
android:background=”#FFFF0000″
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_a”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_b”
android:layout_span=”2″
android:gravity=”center_horizontal”
android:background=”#FF0000FF”
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_g”
android:layout_span=”3″
android:gravity=”center_horizontal”
android:background=”#FFC0C0C0″
android:padding=”3dip” />
</TableRow>
</TableLayout>
<TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>
<TableRow>
<TextView
android:text=”@string/table_layout_12_a”
android:background=”#FFFF0000″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_b”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_c”
android:background=”#FF0000FF”
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_d”
android:layout_span=”2″
android:gravity=”center_horizontal”
android:background=”#FF0000FF”
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_e”
android:background=”#FF00FF00″
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_f”
android:background=”#FFFF00FF”
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_g”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_h”
android:background=”#FFFF0000″
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_a”
android:background=”#FF00FF00″
android:padding=”3dip” />
<TextView
android:text=”@string/table_layout_12_b”
android:layout_span=”2″
android:gravity=”center_horizontal”
android:background=”#FF0000FF”
android:padding=”3dip” />
</TableRow>
<TableRow>
<TextView
android:text=”@string/table_layout_12_g”
android:layout_span=”3″
android:gravity=”center_horizontal”
android:background=”#FFC0C0C0″
android:padding=”3dip” />
</TableRow>
</TableLayout>
相关文章推荐
- Android ApiDemos示例解析(158):Views->Layouts->TableLayout->03.Long Content
- Android ApiDemos示例解析(159):Views->Layouts->TableLayout->04.Stretchable
- Android ApiDemos示例解析(156):Views->Layouts->TableLayout->01. Basic
- Android ApiDemos示例解析(162):Views->Layouts->TableLayout->07. Column Collapse
- Android ApiDemos示例解析(160):Views->Layouts->TableLayout->05. Spanning and Stretchable
- Android ApiDemos示例解析(164):Views->Layouts->TableLayout->09. Toggle Shrink
- Android ApiDemos示例解析(165):Views->Layouts->TableLayout->10. Simple Form
- Android ApiDemos示例解析(161):Views->Layouts->TableLayout->06. More Spanning and Stretchable
- Android ApiDemos示例解析(163):Views->Layouts->TableLayout->08. Toggle Stretch
- Android ApiDemos示例解析(157):Views->Layouts->TableLayout->02. Empty Cells
- Android ApiDemos示例解析(166):Views->Layouts->TableLayout->11. Gravity
- Android ApiDemos示例解析(143):Views->Layouts->LinearLayout->3. Vertical (Padded)
- Android ApiDemos示例解析(146):Views->Layouts->LinearLayout->6. Uniform Size
- Android ApiDemos示例解析(148):Views->Layouts->LinearLayout->8. Gravity
- Android ApiDemos示例解析(149):Views->Layouts->LinearLayout->9. Layout Weight
- Android ApiDemos示例解析(145):Views->Layouts->LinearLayout->5.Simple Form
- Android ApiDemos示例解析(141):Views->Layouts->LinearLayout->1. Vertical
- Android ApiDemos示例解析(144):Views->Layouts->LinearLayout->4. Horizontal
- Android ApiDemos示例解析(150):Views->Layouts->LinearLayout->10. Background Image
- Android ApiDemos示例解析(142):Views->Layouts->LinearLayout->2. Vertical (Fill Screen)