Android开发之实现简单的用户登录及登陆界面的UI设计(五)

这篇具有很好参考价值的文章主要介绍了Android开发之实现简单的用户登录及登陆界面的UI设计(五)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

登陆界面的UI设计

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#03A9F4"
    android:orientation="vertical"
    android:padding="30sp">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!--头像-->
    <ImageView
        android:id="@+id/one_image_0"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/xionger" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!--用户名和密码输入处使用嵌套布局-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/one_image_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/user" />

        <EditText
            android:id="@+id/one_edit_1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入账号" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/one_image_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/password" />

        <EditText
            android:id="@+id/one_edit_2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入密码" />
    </LinearLayout>

    <!--相对布局-->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/one_text_1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="忘记密码?"
            android:textAlignment="textEnd"
            android:textColor="@color/white" />
    </RelativeLayout>

    <Button
        android:id="@+id/one_button_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="登录"
        android:textSize="20sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center">

        <TextView
            android:id="@+id/one_text_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/one_button_1"
            android:text="还不是会员?"
            android:textColor="#756E6E"
            android:textSize="15sp" />

        <TextView
            android:id="@+id/one_text_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="免费注册"
            android:textColor="@color/white"
            android:textSize="15sp" />
    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:id="@+id/one_text_4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/one_button_1"
        android:text="-关联社交账号登录-"
        android:textAlignment="center"
        android:textColor="@color/white"
        android:textSize="15sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center">

    <ImageView
        android:id="@+id/one_image_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/weixin" />

    <ImageView
        android:id="@+id/one_image_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/qq" />

    <ImageView
        android:id="@+id/one_image_5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/weibo" />
    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

编写Java代码,进行简单的用户账号和密码判断文章来源地址https://www.toymoban.com/news/detail-511098.html

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class OneActivity extends AppCompatActivity {

    EditText oneEdit1;
    EditText oneEdit2;

    Button oneButton1;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_one);

        //初始化UI界面
        oneEdit1=findViewById(R.id.one_edit_1);
        oneEdit2=findViewById(R.id.one_edit_2);
        oneButton1=findViewById(R.id.one_button_1);

        //设置监听器,监听按钮事件
        oneButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //设置两个接收用户名和密码的参数
                String user=oneEdit1.getText().toString().trim();
                String password=oneEdit2.getText().toString().trim();

                //判断用户名和密码是否为zhansan和ganfan
                if ("zhansan".equals(user) && "ganfan".equals(password)){
                    Toast.makeText(OneActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
                }else {
                    Toast.makeText(OneActivity.this, "登陆失败", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
}

到了这里,关于Android开发之实现简单的用户登录及登陆界面的UI设计(五)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 界面开发(2)--- 使用PyQt5制作用户登陆界面

    上篇文章已经介绍了如何配置PyQt5环境,这篇文章在此基础上展开,主要记录一下如何使用 PyQt5 制作用户登陆界面,并对一些基础操作进行介绍。 下面是具体步骤,一起来看看吧! 1. 打开 Pycharm 中的 Qt Designer 工具。 2. 选择Main Window模式,创建界面窗口。 3. 移除菜单栏和状态

    2024年02月05日
    浏览(46)
  • 鸿蒙开发(九)UI实战 - 线性布局实现登录界面

        前面我们花了很多章去讲述鸿蒙开发的UI,包括布局和控件等。本篇,我们综合使用布局和控件,完成一个简单的用户登录界面。     简单回忆下我们掌握的几种布局,线性布局的控件横向或纵向线性排列,非常适合实现登录界面,因此我们使用线性布局来实现登录界面

    2024年04月27日
    浏览(24)
  • ElementUI之登陆+注册->饿了吗完成用户登录界面搭建,axios之get请求,axios之post请求,跨域,注册界面

     饿了吗完成用户注册登录界面搭建 axios之get请求 axios之post请求 跨域 注册界面 1.饿了吗完成用户注册登录界面搭建 将端口号8080改为8081 导入依赖,在项目根目录使用命令npm install element-ui -S,添加Element-UI模块 -g:将依赖下载node_glodal全局依赖 -d(依赖放在static/[]package.json的

    2024年02月04日
    浏览(41)
  • Android Studio Kotlin 简单实现微信主界面UI

                            windows11                         文件版本 2023.2.0.0                         产品版本 2023.2.0.AI-232.10227.8.2321._BUILD_NUMBER_         JAVA属性:                          java version \\\"17.0.10\\\" 2024-01-16 LTS       

    2024年04月16日
    浏览(47)
  • 安卓学习1:简单的用户登录注册界面

            a.方法一:创建时直接选择设置为启动界面(勾选LauncherActivity)         b.方法二:手动配置AndroidManifest.xml文件,注册该活动为启动界面                                           不同页面之间的跳转使用Intent对象,它可以用于在不同组件之间传递消息  

    2024年02月02日
    浏览(30)
  • Android学习(一)--用户登录注册界面(界面跳转+背景音乐)

    目录 1.功能要求 2.功能实现流程图 3.功能演示 4.界面与功能  4.1登录界面 4.1.1界面展示 4.1.2登录界面功能简介 4.1.3界面代码 4.1.4登录按钮点击事件 4.1.5退出按钮点击事件  4.1.6背景音乐点击事件 4.1.7记住密码 5.Java源码 (1)三个界面布局,体现文本框、编辑框、单选按钮、复

    2024年02月05日
    浏览(34)
  • Android Studio制作简单登录界面

    应用线性布局设计登录界面,要求点击输入学号时弹出数字键盘界面,点击输入密码时弹出字母键盘,出现的文字、数字、尺寸等全部在values文件夹下相应.xml文件中设置好,使用时直接引用。当用户名或密码为空,显示一个提示信息“用户名与密码不能为空!”,当用户名和

    2024年04月15日
    浏览(40)
  • 【Android】UI布局之线性布局(登录界面代码)

    1、布局管理 组件在activity中呈现的方式,包含组件大小、间距、对齐方式 Android提供了两种布局的实现方式: .在xml配置文件中声明,通过setContentView(R.layout.main)方法呈现在activity中,通过findViewById()方法获得组件实例。(一般推荐这种方式) 动态生成组件以及设置相关布局

    2024年02月11日
    浏览(37)
  • Android快速入门-----用户界面(上)UI组件(1)

    @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ // 提示 Toast.makeText(SimpleComponActivity.this, cd_simple_pingpang.getText().toString(), 0).show(); } } }); cd_simple_foot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton but

    2024年04月17日
    浏览(40)
  • Android studio编写一个简单的登录界面

    1首先先创建一个空的activity项目,接着设置自己的项目名称,勾选上lacuncher 创建成功后点开 manifests 把刚刚创建的文件名下面的 intent-filter 这一行全部删除 然后点开res,复制一张图片,右键drawable点击粘贴,这里放的是图片资源,用于放置登录头像 然后点开layout文件,开始编

    2024年04月15日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包