一、表格布局 TableLayout
表格布局TableLayout以行列的形式管理子元素,每一行是一個(gè)TableRow布局對(duì)象,當(dāng)然也可以是普通的View對(duì)象,TableRow離每放一個(gè)元素就是一列,總列數(shù)由列數(shù)最多的那一行決定。
我們看一個(gè)例子:
<?xml version=”1.0″ encoding=”utf-8″?><TableLayout android:id=”@+id/TableLayout01″android:layout_width=”fill_parent” android:layout_height=”fill_parent”android:stretchColumns=”0″ xmlns:android=”http://schemas.android.com/apk/res/android”><TableRow android:layout_width=”fill_parent”android:layout_height=”20dip”><TextView android:text=”色彩透明度測(cè)試” android:textSize=”18dip”android:layout_span=”2″ 合并兩列android:layout_gravity=”center”android:layout_width=”fill_parent” android:layout_height=”fill_parent”></TextView>
在看下顯示效果圖:

其中 android:stretchColumns=”0″ 作用是讓第一列可以擴(kuò)展到所有可用空間;下面我們講一下TableLayout幾個(gè)重要的屬性: