在上一篇文章中,我們已經完成了 登入介面 的所有前端流程,使用者能夠順利輸入帳號密碼並進行登入。
今天,我將帶領大家打造 註冊介面 (Register UI),讓行程管家除了能登入之外,也能新增使用者帳號,正式讓 登入與註冊畫面互相串聯、跳轉連動,提升應用的完整性。
activity_register ui介面
以下是我們設計好的 activity_register.xml 程式碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.register.RegisterActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/rest_imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:src="@drawable/tc_icon" />
<TextView
android:id="@+id/rest_textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="會員註冊"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/rest_textView_rne"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="使用者名稱(user_name)"
android:gravity="center"
android:textSize="13sp"
android:textStyle="bold"/>
<EditText
android:id="@+id/rest_editTextText_rne"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="text"
android:hint="name" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/rest_textView_rel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:text="電子信箱(email)"
android:textSize="13sp"
android:textStyle="bold"/>
<EditText
android:id="@+id/rest_editTextTextEmailAddress_rem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="textEmailAddress"
android:hint="email" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/rest_textView_rpw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="密碼(password)"
android:textStyle="bold"
android:textSize="13sp"
android:gravity="center"/>
<EditText
android:id="@+id/rest_editTextTextPassword_rpw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="textPassword"
android:hint="password"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/rest_textView_rph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="手機號碼(phone)"
android:textStyle="bold"
android:textSize="13sp"
android:gravity="center"/>
<EditText
android:id="@+id/rest_editTextPhone_rph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="phone"
android:hint="phone"/>
</LinearLayout>
<CheckBox
android:id="@+id/rest_checkBox"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:text="我不是機器人"
android:textStyle="bold"
android:textSize="15sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/rest_button_reg"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:text="註冊"
android:textStyle="bold"
android:textSize="15sp"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
成果展示: