<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TableLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:stretchColumns="0"
>
<TableRow
android:id="@+id/tabrow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="表格布局的使用"
android:textColor="#000000"
android:padding="4px"
android:background="#fd8d8d"
></TextView>
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/mytab2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2,3"
>
<TableRow
android:id="@+id/tabrow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/buton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
/>
<Button
android:id="@+id/buton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
/>
<Button
android:id="@+id/buton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"
/>
<Button
android:id="@+id/buton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button4"
/>
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/tablayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0"
>
<TableRow
android:id="@+id/tabrow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<EditText
android:text="查询"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/text1"
/>
</TableRow>
</TableLayout>
</LinearLayout>
collapseColumns – 设置隐藏那些列,列ID从0开始,多个列的话用”,”分隔
stretchColumns – 设置自动伸展那些列,列ID从0开始,多个列的话用”,”分隔
shrinkColumns -设置自动收缩那些列,列ID从0开始,多个列的话用”,”分隔
可以用”*”来表示所有列,同一列可以同时设置为shrinkable和stretchable。