利用相对布局实现用户注册功能

本文档介绍了如何利用相对布局来实现用户注册功能。详细讲述了布局文件的创建过程,包括注册界面、显示信息界面的XML代码,以及各自对应的事件响应代码实现。
摘要由CSDN通过智能技术生成

运行效果如下图所示:
在这里插入图片描述

一、实现布局文件:
1、注册界面代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="@mipmap/backgroundimg"
    android:padding="15dp"
    tools:context=".RegistrationActivity">

    <TextView
        android:id="@+id/tv_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="20dp"
        android:text="@string/title"/>

    <TextView
        android:id="@+id/tv_username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textColor="#000000"
        android:layout_marginBottom="15dp"
        android:layout_below="@id/tv_title"
        android:text="@string/username"/>

    <EditText
        android:id="@+id/edt_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/tv_username"
        android:layout_alignBaseline="@id/tv_username"
        android:layout_below="@id/tv_title"
        android:singleLine="true"
        android:hint="@string/input_username"/>

    <TextView
        android:id="@+id/tv_password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textColor="#000000"
        android:layout_marginBottom="15dp"
        android:layout_below="@id/tv_username"
        android:text="@string/password"/>

    <EditText
        android:id="@+id/edt_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/tv_password"
        android:layout_alignLeft="@id/edt_username"
        android:layout_alignBaseline="@id/tv_password"
        android:layout_below="@id/edt_username"
        android:singleLine="true"
        android:inputType="textPassword"
        android:hint="@string/input_password"/>

    <TextView
        android:id="@+id/tv_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textColor="#000000"
        android:layout_marginBottom="15dp"
        android:layout_below="@id/tv_password"
        android:text="@string/phone"/>

    <EditText
        android:id="@+id/edt_phone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/tv_phone"
        android:layout_alignLeft="@id/edt_password"
        android:layout_alignBaseline="@id/tv_phone"
        android:layout_below="@id/edt_password"
        android:singleLine="true"
        android:inputType="phone"
        android:hint="@string/input_phone"/>

    <TextView
        android:id="@+id/tv_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:textColor="#000000"
        android:layout_marginBottom="15dp"
        android:layout_below="@id/tv_phone"
        android:text="@string/email"/>

    <EditText
        android:id="@
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值