Android UI教程 - Android TableLayout
Android UI教程 - Android TableLayout
TableLayout将视图分组到行和列。
您可以使用< TableRow> 元素来指定表中的一行。 每行可以包含一个或多个视图。
您放置在行内的每个视图形式细胞。 每列的宽度为由该列中每个单元格的最大宽度确定。
例子
<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 /> 空元素填充。