效果展示

虽然说以前学了点,但是还是是个菜鸡。现在又来学一哈,hhh。Java大法好

先看看效果图吧

项目地址

百度云:链接:https://pan.baidu.com/s/1Zq7Voo-KW6_AkZIqdgap4g 提取码:u0ze

蓝凑云:https://yxqz.lanzoui.com/ilpyWgqpene

布局介绍

  1. 帧布局 framelayout
  2. 线性布局 LinearLayout
  3. 表格布局 TableLayout
  4. 相对布局 RelativeLayout

帧布局

可以理解为相框,里面的视图就是照片

  • 默认在左上角
  • 后方的视图会往上叠加,从而覆盖之前的视图

线性布局

  • 像一个需要按顺序排放的展柜
  • 可以规定线性布局是按竖直和横向排列

表格布局

  • 由行和列构成
  • 将视图放在行和列组成的单元格里

相对布局

  • 一种很灵活的布局方式
  • 放入的视图位置可以根据已有视图的相对位置确定
  • 默认的Android布局

图片位置

在app下的res下的drawable下面

登录页面

登录界面(activity_main.xml)

使用了表格布局,还有线性布局,纯手打。hhh。拖动我英语不行,懒得汉化了。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/shoujibizhi"tools:context=".MainActivity"><!--欢迎处的表格布局   --><TableLayoutandroid:layout_width="match_parent"android:layout_height="200dp"android:gravity="center"><!--    欢迎字体--><TextViewandroid:gravity="center"android:text="欢迎登录"android:textColor="#B97E05"android:textSize="40dp"></TextView></TableLayout><!--    文本框的Ta布局--><TableLayoutandroid:layout_width="match_parent"android:layout_height="200dp"android:gravity="center"><!--        用户名--><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="用户名:"android:textColor="#B97E05" /><EditTextandroid:id="@+id/usernameET"android:layout_width="200dp"android:layout_height="wrap_content" /></LinearLayout><!--        密码--><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密     码:"android:textColor="#B97E05" /><EditTextandroid:id="@+id/passET"android:layout_width="200dp"android:layout_height="wrap_content"android:password="true" /></LinearLayout>
<!--        账号和密码提示--><LinearLayoutandroid:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="20dp"android:textColor="#BA0109"android:text="用户名是admin,密码是123"/></LinearLayout></TableLayout><!--    按钮的Tab布局--><TableLayoutandroid:layout_width="wrap_content"android:layout_height="200dp"android:gravity="center">
<!--        使用线性布局--><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"><Buttonandroid:id="@+id/loginButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background=" #F3DB26"android:text="登 录"android:textSize="18dp" /><Buttonandroid:id="@+id/zcButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="100dp"android:background=" #F3B2"android:text="注册"android:textSize="18dp" /></LinearLayout></TableLayout></TableLayout>

属性解析

  1. android:layout_width=“match_parent”:界面宽度,match_parent表示充满屏幕 这里是让宽度充满屏幕可以用行来理解
  2. android:layout_height=“match_parent” 界面高度。wrap_content表示根据内容来调节,这里是调节高度
  3. layout_marginLeft:界面左边外边距.
  4. gravity=“center”:内容居中
  5. android:layout_gravity=“center”:界面居中
  6. android:password=“true”:密码属性

逻辑代码(MainActivity.java)

package com.yq.text;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;public class MainActivity extends AppCompatActivity {private Button lgButton, zcButton;private EditText usernameText, passText;@RequiresApi(api = Build.VERSION_CODES.M)@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate( savedInstanceState );
//        设置页面布局 ,main界面setContentView( R.layout.activity_main );//设置此界面为竖屏setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
//       初始化方法init();}@RequiresApi(api = Build.VERSION_CODES.M)private void init() {//从main.xml 页面布局中获取对应的UI控件lgButton = (Button) findViewById( R.id.loginButton );zcButton = (Button) findViewById( R.id.zcButton );usernameText = (EditText) findViewById( R.id.usernameET );passText = (EditText) findViewById( R.id.passET );
// 注册按钮监听zcButton.setOnClickListener( new OnClickListener() {//注册按钮实现事件public void onClick(View v) {Toast.makeText( MainActivity.this, "老师没说做这个", Toast.LENGTH_SHORT ).show();}} );//登录按钮的点击事件lgButton.setOnClickListener( new OnClickListener() {@Overridepublic void onClick(View v) {//非空if ("".equals( usernameText.getText().toString() ) == true ||"".equals( passText.getText().toString() ) == true) {Toast.makeText( MainActivity.this, "没有输入账号或者密码~~~", Toast.LENGTH_SHORT ).show();// 逻辑判断} else if ("admin".equals( usernameText.getText().toString() ) == true &&"123".equals( passText.getText().toString() ) == true) {//提示用户名Toast.makeText(MainActivity.this, "欢迎你:"+usernameText.getText().toString(), Toast.LENGTH_SHORT).show();//创建登录成功界面对象Intent intent = new Intent( MainActivity.this, LoginSourcess.class );startActivity( intent );//打开界面MainActivity.this.finish();//终结登录界面}else{//输入要错误提示Toast.makeText(MainActivity.this, "请不要乱输入", Toast.LENGTH_SHORT).show();}}} );}
}

登录成功的页面

成功页面(loginsoucess.xml)

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/shouj"tools:context=".MainActivity"><TextViewandroid:textSize="100dp"android:text="登录成功"/>
</TableLayout>

逻辑代码(LoginSourcess.java)

package com.yq.text;import android.content.pm.ActivityInfo;
import android.os.Bundle;import androidx.appcompat.app.AppCompatActivity;public class LoginSourcess extends AppCompatActivity {protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
//        设置页面布局setContentView(R.layout.loginsoucess);//设置此界面为竖屏setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);}
}

页面配置

这里是很多人忘记配置的地方,也是做跳转的时候,会报一个页面无法打开的异常

找到app下的manifests文件夹里的AndroidManifest.xml文件

在application标签下添加新建的登录成功页面.这里是通过调用java文件来对页面进行操作。

        <activity android:name=".LoginSourcess"/>

Android安卓登录页面相关推荐

  1. Android注册登录页面

    Android注册登录页面 需求 分析 项目目录 .java domain JsonBean.java UserInfo.java utils GetJsonDataUtil.java Login.j ...

  2. Android微信登录页面实现

    利用Android实现微信手机端的登录页面,对于登录的输入做了一些的条件限制诸如,非空,长度限制等: 效果图如下: xml文件代码: <?xml version="1.0" ...

  3. Android:基础控件按键文本框输入框制作登录页面

    基础控件之Button,TextView,EditText,ImageView Button:按键 TextView:文本框 EditText:输入框 ImageView:图片 那我们新建一个工程研究 ...

  4. android自动登录简书,安卓实现用户登录界面

    这个是我们社团的作业,本人大一,也是刚刚接触安卓,很多东西都很陌生,不懂得问我们的学长,学长觉得问题太简单了不予回答O__O "-然而很多细节困扰了我很久,去网上找方法也费了好多的冤枉时间, ...

  5. android开发我的新浪微博客户端-登录页面UI篇(4.1)

    首先回顾一下功能流程当用户开启软件显示载入页面时程序首先去sqlite库查询是否已经保存有用户的新浪微博的UserID号.Access Token.Access Secret的记录如果没有一条记录那么 ...

  6. 【Android应用开发之前端——简易App登录页面】

    1.完成登录页面布局 各家App的登录页面大同小异,要么是用户名和密码组合登录,要么是手机号和验证码组合登录.如果要做的更好一点,就要提供忘记密码与记住密码等功能.我们的App登录项目把这些功能综合一 ...

  7. Android 简易QQ登录页面

    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=&q ...

  8. android 登陆界面动画,【Android开发】动画登录页面

    心得感悟 这个Demo对我还是比较有难度的,花了好久去理解.因为动画比较有趣,所以想自己改改样式,也有助于自己的理解.这是进入Android开发学习第六天了,每天的学习都是懂了很多,却还有很多不懂,还 ...

  9. Android开发实现简单QQ登录页面

    Android开发实现极为简单的QQ登录页面 设计一个简单QQ登录页面,无任何功能.然后打包安装到手机. 1.首先创建一个空白页面 2.打开样式设计的页面 在activity_main.xml中写入代 ...

最新文章

  1. 一行代码搞定 Python 逐行内存消耗分析
  2. IJCV2021 人脸关键点检测器PIPNet
  3. Spring配置多数据源错误总结
  4. 无法打开此修补程序包”或“这个产品的安装来源无法使用”解决(转)
  5. 鸿蒙十系统更新机型,高歌猛进,鸿蒙系统升级机型再次确认,花粉:终等到!...
  6. Gigaset ME/pure/pro体验:就是这个德味
  7. 手机号码归属地及运营商查询
  8. Linux 命令(95)—— test 命令
  9. Vosviewer图谱相关指标详细解释1
  10. 使用EditPlus 3时,如何重新设置HTML Page的Default模板
  11. 腾讯云 DDNS 方案
  12. Film Stocks for Mac(PS胶片模拟调色插件)
  13. CCKS2019总结
  14. 【SpringBoot】MultipartResolver文件解析器
  15. 苹果手机无线网显示无网络连接到服务器,iPhone提示:“无线局域网似乎未接入互联网”,咋回事?...
  16. 使用Websphere的TPTP工具进行性能分析和监控
  17. php 之session 进行时
  18. php如何锁定表,PHPExcel冻结(锁定)表头的简单实现方法
  19. 网上订餐管理系统的设计与实现
  20. SharePoint BI培训资料

热门文章

  1. USART串口通信实验
  2. 2-1. Maven 三层项目结构搭建
  3. win7安装python错误0x80072f7d
  4. MATLAB产生按顺序排列的自然数一维向量
  5. 一文带你读懂SDK测试
  6. vue-wangEditor 上传视频功能
  7. Broadcasted Residual Learning for Efficient Keyword Spotting(2021)
  8. 计算机专业评职称要不要工作年限,评职称对工作年限要求严格吗
  9. 树莓派:无显示器PC远程控制树莓派,通过网线orWiFi
  10. 苹果x为什么是android,为什么苹果手机如此受欢迎?这是很多安卓用户一直想不通的点...