<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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TableLayout android:stretchColumns="1" android:layout_width="match_parent" android:layout_height="wrap_content" > <TableRow > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓名" /> <EditText android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <TableRow > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密码" /> <EditText android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <TableRow > <Button android:text="取消" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="取消" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> </TableLayout> </LinearLayout>
TableLayout最大的列数是所有位于TableLayout中的TableRow的列数中的,即列数最多的一行有多少列。TableLayout就有多少列。
android:stretchColumns="1"用来指定那一列被拉伸。