TableLayout將視圖分組到行和列。
您可以使用< TableRow>
元素來指定表中的一行。 每行可以包含一個或多個視圖。
您放置在行內(nèi)的每個視圖形式細胞。 每列的寬度為由該列中每個單元格的最大寬度確定。
<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>
在前面的示例中, TableLayout
中有兩列和四行。直接在密碼 TextView
下的單元格用< TextView />
空元素填充。
更多建議: