Android——表格佈局管理器

在佈局管理器上所設置的屬性

android:collapseColumns刪除某列
android:stretchColumns允許被拉伸
android:shrinkColumns允許被收縮

android:collapseColumns="1" 
android:stretchColumns="0,1,2" 
android:shrinkColumns="1"  

樣例1

在這裏插入圖片描述

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="0,1">

    <TableRow
        android:layout_weight="1">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#ff0000"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#00ff00"
            />
    </TableRow>
    <TableRow
        android:layout_weight="1">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#ffff00"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#0000ff"
            />
    </TableRow>
</TableLayout>

樣例2

在這裏插入圖片描述

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/aa"
    android:shrinkColumns="1"
    android:stretchColumns="0,3">

    <TableRow android:paddingTop="200dp">

        <TextView
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="賬  號"
            android:textColor="#aaaaaa"
            android:textSize="25dp" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:hint="郵箱或手機號"
            />
        <TextView />
    </TableRow>

    <TableRow
        >
        <TextView />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="密  碼"
            android:textColor="#aaaaaa"
            android:textSize="25dp" />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="輸入密碼"
            />
        <TextView />
    </TableRow>
    <TableRow
        >
        <TextView />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="註冊"
            android:textColor="#545455"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />
        <TextView />
    </TableRow>
    <TableRow android:paddingTop="20dp">
        <TextView />
        <TextView />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="忘記密碼?"
            android:textColor="#FF5722"
            />
    </TableRow>
</TableLayout>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章