1. 程式人生 > >安卓登入介面

安卓登入介面

安卓應用登入介面


1.實現安卓登入介面基本樣式
在這裡插入圖片描述
2.涉及安卓介面基本佈局xml
3.基本採用線性佈局,將元件依次排序
在這裡插入圖片描述



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

	//1.LinearLayout 佈局,將其他元件巢狀進裡面
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/login_layout"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:gravity="center">
		//將賬號文字框放好
        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/usename_layout"
            android:layout_marginTop="55dp"
            android:gravity="center">
            
            <EditText
                android:layout_width="fill_parent"
                android:layout_height="40dp"
                android:id="@+id/usename"
                android:layout_marginTop="5dp"
                android:inputType="number"
                android:paddingRight="60dp"
                android:maxLength="20"
                android:paddingLeft="55dp"
                android:paddingTop="5dp"/>
			
            <TextView
                android:layout_width="50dp"
                android:layout_height="35dp"
                android:layout_marginStart="8dp"
                android:layout_gravity="left|center_vertical"
                android:text="@string/longin"
                android:textSize="20dp"
                android:layout_marginLeft="8dp" />
		
        </FrameLayout>
        ////將密碼文字框放好
        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/usecode_layout"
            android:layout_below="@id/usename_layout"
            android:layout_marginTop="6dp"
            android:gravity="center" >

            <EditText
                android:id="@+id/password"
                android:layout_width="fill_parent"
                android:layout_height="55dp"
                android:inputType="textPassword"
                android:maxLength="20"
                android:paddingLeft="55dp"
                android:paddingRight="60dp"
                android:paddingTop="5dp"/>

            <TextView
                android:layout_width="50dp"
                android:layout_height="35dp"
                android:layout_marginStart="8dp"
                android:layout_gravity="left|center_vertical"
                android:text="@string/longin"
                android:textSize="20dp"
                android:layout_marginLeft="8dp" />

        </FrameLayout>
		//三個按鈕
        <Button
            android:id="@+id/login"//登入按鈕
            android:layout_width="fill_parent"
            android:layout_height="44dp"
            android:layout_below="@id/usecode_layout"
            android:layout_marginTop="30dp"
            android:background="#ff336699"
            android:textColor="@android:color/white"
            android:gravity="center"
            android:text="登入" />
        <Button
            android:id="@+id/login_error"//忘記密碼的按鈕
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignRight="@id/login"
            android:layout_below="@id/login"
            android:background="#00000000"
            android:text="忘記密碼"
            android:textSize="16sp" />
        <Button
            android:id="@+id/register"//註冊按鈕
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/login"
            android:layout_below="@id/login"
            android:background="#00000000"
            android:gravity="left|center_vertical"
            android:text="註冊"
            android:textSize="16sp"
            android:visibility="visible" />

    </RelativeLayout>
</LinearLayout>