Android佈局管理器-使用TableLayout表格佈局管理器實現簡單的用戶登陸頁面

場景

Android佈局管理器-使用FrameLayout幀佈局管理器顯示層疊的正方形以及前景照片:android

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103839149編程

實現效果以下app

 

 

注:佈局

博客:
https://blog.csdn.net/badao_liumang_qizhi
關注公衆號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。spa

實現

將activity_main.xml修改成TableLayout.net

 

 

而後使用<TabelRow>標籤表明添加一行,首行使用code

android:paddingTop="200dp">

 

設置頂部內邊距xml

第一行,添加空的TextView,再添加一個水平居中的TextView和一個EditTextblog

 <TableRow
        android:paddingTop="200dp">
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="帳  號:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="輸入郵箱或手機號"
            />
    </TableRow>

 

第二行,同理,改成密碼輸入行,不用再設置內頂邊距教程

<TableRow>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密  碼:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="輸入6-16位數字或字母"
            />
    </TableRow>

 

第三行添加註冊和登陸按鈕

    <TableRow>
        <TextView/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注  冊"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登  錄"
            android:background="#FF8247"
            />
    </TableRow>

 

第四行,添加忘記密碼提示

<TableRow
        android:paddingTop="20dp"
        >
        <TextView/>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#FF4500"
            android:text="忘記密碼?"
            android:gravity="right"
            />
        <TextView/>
    </TableRow>

 

完整示例代碼

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TableLayoutActivity">

    <TableRow
        android:paddingTop="200dp">
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="帳  號:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="輸入郵箱或手機號"
            />
    </TableRow>

    <TableRow>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密  碼:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="輸入6-16位數字或字母"
            />
    </TableRow>

    <TableRow>
        <TextView/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注  冊"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登  錄"
            android:background="#FF8247"
            />
    </TableRow>

    <TableRow
        android:paddingTop="20dp"
        >
        <TextView/>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#FF4500"
            android:text="忘記密碼?"
            android:gravity="right"
            />
        <TextView/>
    </TableRow>

</TableLayout>
相關文章
相關標籤/搜索