安卓学习 之 模拟登录界面

经过昨天一天的调试,今天终于可以正常模拟了,由于电脑的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>  //线性布局结束
相关推荐
2601_949809592 分钟前
flutter_for_openharmony家庭相册app实战+我的Tab实现
java·javascript·flutter
vx_BS8133031 分钟前
【直接可用源码免费送】计算机毕业设计精选项目03574基于Python的网上商城管理系统设计与实现:Java/PHP/Python/C#小程序、单片机、成品+文档源码支持定制
java·python·课程设计
2601_9498683631 分钟前
Flutter for OpenHarmony 电子合同签署App实战 - 已签合同实现
java·开发语言·flutter
星火开发设计1 小时前
类型别名 typedef:让复杂类型更简洁
开发语言·c++·学习·算法·函数·知识
达文汐1 小时前
【困难】力扣算法题解析LeetCode332:重新安排行程
java·数据结构·经验分享·算法·leetcode·力扣
培风图南以星河揽胜1 小时前
Java版LeetCode热题100之零钱兑换:动态规划经典问题深度解析
java·leetcode·动态规划
Gorgous—l1 小时前
数据结构算法学习:LeetCode热题100-多维动态规划篇(不同路径、最小路径和、最长回文子串、最长公共子序列、编辑距离)
数据结构·学习·算法
启山智软1 小时前
【中大企业选择源码部署商城系统】
java·spring·商城开发
我真的是大笨蛋1 小时前
深度解析InnoDB如何保障Buffer与磁盘数据一致性
java·数据库·sql·mysql·性能优化
Hello_Embed2 小时前
libmodbus 移植 STM32(基础篇)
笔记·stm32·单片机·学习·modbus