The TableLayout groups views into rows and columns.
You use the <TableRow>
element to designate
a row in the table. Each row can contain one or more views.
Each view you place within a row forms a cell. The width of each column is determined by the largest width of each cell in that column.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" > <TableRow> <TextView android:text="User Name:" android:width ="120dp" /> <EditText android:id="@+id/txtUserName" android:width="200dp" /> </TableRow> <TableRow> <TextView android:text="Password:" /> <EditText android:id="@+id/txtPassword" android:password="true" /> </TableRow> <TableRow> <TextView /> <CheckBox android:id="@+id/chkRememberPassword" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Remember Password" /> </TableRow> <TableRow> <Button android:id="@+id/buttonSignIn" android:text="Log In" /> </TableRow> </TableLayout>
In the preceding example, there are two columns and four rows in the TableLayout
.
The cell directly under the Password TextView
is populated with a <TextView/>
empty element.