安卓学习 之 模拟登录界面

经过昨天一天的调试,今天终于可以正常模拟了,由于电脑的C盘满了,今天用了一上午的时间把c盘里没有的文件都删了,腾出来几十GB的空间出来,不然系统要崩溃了,查询了一下,说这是很正常的情况,主要是系统备份的文件比较大,但是恢复期却只有7天,过了7天这个系统备份就没用了,但是也不删除,这样就造成了C盘越用越小的问题了。好了不说这些了,学习了几天了,终于做出一个丑陋的界面并模拟运行了,还是有点小欣喜的。来看看效果吧!

这是在雷电模拟器中运行的结果,现在还不会生成App程序放到真机中运行,相信有一天会做到的。

下面展示一下这个界面的代码吧:其实代码中是不能单行注释的,我这么写只是为了自己看着明白而已,如果想复制记得自行删除,不然会报错的。

XML 复制代码
<?xml version="1.0" encoding="utf-8"?>
<!--  整体线性布局  -->
<LinearLayout 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=".MainActivity"
    android:orientation="vertical"        //垂直布局
    android:background="@mipmap/tiankong"
    android:gravity="center_horizontal">  //线性布局中的元素都居中显示

    <TextView  //文本控件
        android:layout_width="wrap_content" //宽度根据内容来
        android:layout_height="wrap_content" //高度根据内容来
        android:text="注册"    //文本:注册
        android:textSize="28sp" //28号字体
        android:layout_margin="30dp"  //内边距30像素
        android:visibility="visible"  //这个属性是:是否可见
        />
    <!--invisible:不可见但保留位置  visible:可见 gone:不可见,不保留位置-->
    <TextView  //文本控件
        android:layout_width="wrap_content"  //宽度根据内容来
        android:layout_height="wrap_content" //高度根据内容来
        android:text="kjaossadkngkjnashohosaidnkjsadhgoipashgognsadkn" //文本
        android:textSize="18sp"  //18号字体
        android:layout_margin="20dp" //内边距20像素
        android:gravity="center_horizontal" //内部文字的重力是居中显示
        />

    <ImageView  //图片控件
        android:layout_width="wrap_content" //宽度根据图片来
        android:layout_height="75dp"       //高度75像素
        android:src="@mipmap/yuan"       //图片来源
        android:layout_margin="10dp"/>   //内边距10像素

    <EditText  //文本控件
        android:layout_width="match_parent"    //宽度同父容器
        android:layout_height="wrap_content"   //高度根据内容来
        android:gravity="center_horizontal"   //内部元素水平居中
        android:layout_marginLeft="30dp"     //左外边距30像素
        android:layout_marginRight="30dp"   //右外边距30像素
        android:layout_marginTop="10dp"/>   //上外边距10像素

    <EditText  //文本控件
        android:layout_width="match_parent"  //宽度同父容器
        android:layout_height="wrap_content"  //高度根据内容来
        android:gravity="center_horizontal"   //内部重力水平居中
        android:layout_marginLeft="30dp"     //外左边距30像素
        android:layout_marginRight="30dp"   //右外边距30像素
        android:layout_marginTop="20dp"/>   //上外边距20像素

    <EditText
        android:layout_width="match_parent" //宽度同父容器
        android:layout_height="wrap_content"  //高度根据内容来
        android:gravity="center_horizontal"  //内部重力水平居中
        android:layout_marginLeft="30dp"   //外左边距30像素
        android:layout_marginRight="30dp"  //右外边距30像素
        android:layout_marginTop="20dp"/>   //上外边距20像素

    <EditText
         android:layout_width="match_parent" //宽度同父容器
        android:layout_height="wrap_content"  //高度根据内容来
        android:gravity="center_horizontal"  //内部重力水平居中
        android:layout_marginLeft="30dp"   //外左边距30像素
        android:layout_marginRight="30dp"  //右外边距30像素
        android:layout_marginTop="20dp"/>   //上外边距20像素

    <Button  //按钮控件
        android:layout_width="match_parent"  //宽度同父容器
        android:layout_height="54dp"    //高度54像素
        android:layout_marginLeft="20dp"    //外左边距20像素
        android:layout_marginTop="25dp"  //上外边距25像素
        android:layout_marginRight="20dp"  //右外边距20像素
        android:background="@mipmap/jiahao"  //背景图片来源mipmap文件夹下的jiahao.png
        android:text="登录" />  //文本:登录

</LinearLayout>  //线性布局结束
相关推荐
日月云棠1 天前
各版本JDK对比:JDK 25 特性详解
java
用户8307196840821 天前
Spring Boot 项目中日期处理的最佳实践
java·spring boot
JavaGuide1 天前
Claude Opus 4.6 真的用不起了!我换成了国产 M2.5,实测真香!!
java·spring·ai·claude code
IT探险家1 天前
Java 基本数据类型:8 种原始类型 + 数组 + 6 个新手必踩的坑
java
花花无缺1 天前
搞懂new 关键字(构造函数)和 .builder() 模式(建造者模式)创建对象
java
用户908324602731 天前
Spring Boot + MyBatis-Plus 多租户实战:从数据隔离到权限控制的完整方案
java·后端
桦说编程1 天前
实战分析 ConcurrentHashMap.computeIfAbsent 的锁冲突问题
java·后端·性能优化
程序员清风2 天前
用了三年AI,我总结出高效使用AI的3个习惯!
java·后端·面试
beata2 天前
Java基础-13: Java反射机制详解:原理、使用与实战示例
java·后端
用户0332126663672 天前
Java 使用 Spire.Presentation 在 PowerPoint 中添加或删除表格行与列
java