安卓学习 之 模拟登录界面

经过昨天一天的调试,今天终于可以正常模拟了,由于电脑的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>  //线性布局结束
相关推荐
a31582380614 小时前
Android 大图显示策略优化显示(二)
android·java·开发语言·javascript·kotlin·glide·图片加载
黛色正浓14 小时前
leetCode-热题100-普通数组合集(JavaScript)
java·数据结构·算法
月明长歌14 小时前
Java多线程线程池ThreadPoolExecutor理解总结:6 个核心参数 + 4 种拒绝策略(附完整示例)
java·开发语言
找不到、了14 小时前
JVM 跨代引用与 Card Table 机制
java·jvm
sunywz14 小时前
【JVM】(2)java类加载机制
java·jvm·python
进阶小白猿14 小时前
Java技术八股学习Day13
java·jvm·学习
CodeAmaz14 小时前
ConcurrentHashMap(JDK 7/8)详细介绍
java·hashmap·线程安全map
大猫和小黄14 小时前
Tomcat vs Undertow 全面对比
java·tomcat
行业探路者15 小时前
二维码制作工具使用指南:如何利用电脑摄像头轻松扫描和生成图片二维码
大数据·人工智能·学习·产品运营·软件工程
坏柠15 小时前
从点亮一颗 LED 开始:ESP32-S3 GPIO 输出的正确学习方式
学习