Android Layout Manager - Simple user login page using TableLayout Table Layout Manager

scene

Android Layout Manager - Use FrameLayout Frame Layout Layout to display overlapping squares and foreground photos:

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

The results are as follows

 

 

Note:

Blog:
https://blog.csdn.net/badao_liumang_qizhi
Focus on Public Number
Domineering program ape
Get programming-related e-books, tutorial pushes, and free downloads.

Realization

Modify activity_main.xml to TableLayout

 

 

Then use the <TabelRow>tag to add a line, using the first line

android:paddingTop="200dp">

 

Set top margin

First line, add an empty TextView, then a horizontally centered TextView and an EditText

 <TableRow
        android:paddingTop="200dp">
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Account number:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter a mailbox or mobile number"
            />
    </TableRow>

 

The second line, similarly, changes to the password input line instead of setting the top margin

<TableRow>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Password:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Input 6-16 Digit digits or letters"
            />
    </TableRow>

 

Add Registration and Login buttons on the third line

    <TableRow>
        <TextView/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Registration"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Sign in"
            android:background="#FF8247"
            />
    </TableRow>

 

Fourth line, add a forgotten password hint

<TableRow
        android:paddingTop="20dp"
        >
        <TextView/>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#FF4500"
            android:text="Forgot your password?"
            android:gravity="right"
            />
        <TextView/>
    </TableRow>

 

Complete sample code

<?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="Account number:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter a mailbox or mobile number"
            />
    </TableRow>

    <TableRow>
        <TextView/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Password:"
            android:textSize="18sp"
            android:gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Input 6-16 Digit digits or letters"
            />
    </TableRow>

    <TableRow>
        <TextView/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Registration"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Sign in"
            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="Forgot your password?"
            android:gravity="right"
            />
        <TextView/>
    </TableRow>

</TableLayout>

Tags: Android xml Mobile Programming

Posted on Sun, 05 Jan 2020 12:50:05 -0800 by petersen313