Android UI教程 - Android TableLayout

2018-01-09 14:51 更新

Android UI教程 - Android TableLayout


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>

null


注意

在前面的示例中, TableLayout 中有兩列和四行。直接在密碼 TextView 下的單元格用< TextView /> 空元素填充。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號