Android studio 实现app登录注册页面

编程之家收集整理的这篇文章主要介绍了Android studio 实现app登录注册页面编程之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

内容概述

实现注册界面的布局效果,包含用户名,密码,忘记密码,登录等控件

语音解读

图文解释

目录

activity_main.xml代码如下

MainActivity.java代码如下


用于高校实现Android studio专业课作业提交,如确实有用,欢迎观众姥爷打赏

页面实现了注册页面的布局效果,包含用户名,密码,忘记密码,登录等控件

完成之后是这个样子的界面

  

测试页面,首先输入用户名和密码

点击登录提示需要注册

 废话不多说,直接上干货,直接复制请自修改报错

activity_main.xml代码如下

<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:id="@+id/activity_login"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/amd"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_edit_pwd"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="20dp">

        <Button
            android:id="@+id/login_btn_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="50dp"
            android:layout_marginTop="52dp"
            android:layout_marginRight="50dp"
            android:background="#54b4ff"
            android:text="登录"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <Button
            android:id="@+id/login_btn_register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="260dp"
            android:layout_marginTop="52dp"
            android:background="#54b4ff"
            android:text="注册"
            android:textColor="#ffffff"
            android:textSize="20sp" />
    </RelativeLayout>

    <EditText
        android:id="@+id/login_edit_pwd"
        android:layout_width="400dp"
        android:layout_height="60dp"
        android:layout_below="@+id/login_edit_account"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_marginStart="0dp"
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:drawableLeft="@android:drawable/ic_lock_idle_lock"
        android:ems="10"
        android:hint="请输入您的密码"
        android:inputType="textPassword" />

    <EditText
        android:id="@+id/login_edit_account"
        android:layout_width="400dp"
        android:layout_height="60dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_marginStart="6dp"
        android:layout_marginLeft="6dp"
        android:layout_marginTop="350dp"
        android:drawableLeft="@android:drawable/ic_menu_myplaces"
        android:hint="请输入您的用户名"
        android:inputType="textPersonName"
        tools:ignore="UnkNownId" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_edit_pwd"
        >

        <CheckBox
            android:id="@+id/Login_Remember"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:checked="false"
            android:text="记住密码"
            android:textSize="15sp"/>
        <Button
            android:id="@+id/login_btn_forgetregister"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="0dp"
            android:backgroundTint="#ffffff"
            android:text="忘记密码"
            android:textColor="#000000"
            android:textSize="15sp"/>

    </LinearLayout>
</RelativeLayout>

MainActivity.java代码如下

package com.example.myapplication;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;

public class MainActivity extends AppCompatActivity{
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button=(Button)findViewById(R.id.login_btn_forgetregister);
        button.setonClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){new AlertDialog.Builder(MainActivity.this).setTitle("系统提示").setMessage("请输入验证信息进行验证!")
                    .setPositiveButton("确定",new DialogInterface.OnClickListener(){
                        @Override
                        public void onClick(DialogInterface dialog,int which){
                            finish();
                        }
                    }).setNegativeButton("返回",int which){
                        }

                    }).show();
            }
        });
        Button button1=(Button)findViewById(R.id.login_btn_login);
        button1.setonClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                new AlertDialog.Builder(MainActivity.this).setTitle("系统提示").setMessage("验证成功!")
                        .setNegativeButton("确定",new DialogInterface.OnClickListener(){
                            @Override
                            public void onClick(DialogInterface dialog,int which){
                            }
                        }).show();
            }
        });
        Button button2=(Button)findViewById(R.id.login_btn_register);
        button2.setonClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                new AlertDialog.Builder(MainActivity.this).setTitle("系统提示").setMessage("注册成功!")
                        .setNegativeButton("确定",int which){
                            }
                        }).show();
            }
        });
    }
}

使用了认的两个页面完成了登录页面注册和使用。

注意:直接复制时,请添加自己的背景图片修改文件,其他报错请留言

点赞+关注!!!

如需要帮助请联系小哥哥VX:Doi000101,备注来意。

总结

以上是编程之家为你收集整理的Android studio 实现app登录注册页面全部内容。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给好友。

原文地址:https://blog.csdn.net/weixin_46165323

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方法有哪些的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Android...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Android岛屿数量算...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Andro...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内容详细,步骤清晰,细节处理妥当,希望这篇“Android数据压缩的方法是什么”文章能帮助大家解决疑惑...
这篇“Android怎么使用Intent传大数据”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅...
本文小编为大家详细介绍“Android事件冲突怎么解决悬浮窗拖拽问题”,内容详细,步骤清晰,细节处理妥当,希望这篇“Android事件冲突怎么解决悬浮窗拖拽问题”文...