2009年12月29日星期二

TableLayout (表格佈局)

TableLayout將子元素排成行和列. TableLayout容器不會顯示行, 列或單元格的邊界線. 表格(Table)可以留空單元格, 但單元格不能跨越列.

TableRow對象是TableLayout的子視圖(每個TableRow定義了一個表中的一行). 每一行具有零或多個單元格, 每個單元格被其他View定義. 所以, 一行中的單元格可以由多種視圖對象組成, 如ImageView或TextView對象. 一個單元格也可是ViewGroup對象(例如,您可以嵌套另一個 TableLayout作為一個單元格).



<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:text="TableLayout"
/>
<TableRow>
<TextView
android:text="AAA"
android:background="#808080"
/>
<TextView
android:text="BBB"
android:background="#404040"
/>
</TableRow>

<TableRow>
<TextView
android:text="CCC"
android:background="#404040"
/>
<TextView
android:text="DDD"
android:background="#808080"
/>
<TextView
android:text="EEE"
android:background="#404040"
/>
</TableRow>
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A Button"
/>
</TableRow>
</TableLayout>




沒有留言:

發佈留言