安卓学习 之 模拟登录界面

经过昨天一天的调试,今天终于可以正常模拟了,由于电脑的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>  //线性布局结束
相关推荐
毕设源码-赖学姐2 分钟前
【开题答辩全过程】以 基于net超市销售管理系统为例,包含答辩的问题和答案
java
昀贝12 分钟前
IDEA启动SpringBoot项目时报错:命令行过长
java·spring boot·intellij-idea
xcLeigh12 分钟前
Python入门:Python3 requests模块全面学习教程
开发语言·python·学习·模块·python3·requests
xcLeigh12 分钟前
Python入门:Python3 statistics模块全面学习教程
开发语言·python·学习·模块·python3·statistics
roman_日积跬步-终至千里43 分钟前
【LangGraph4j】LangGraph4j 核心概念与图编排原理
java·服务器·数据库
GHL2842710901 小时前
分析式AI学习
人工智能·学习·ai编程
lpruoyu1 小时前
【Android第一行代码学习笔记】Android架构_四大组件_权限_持久化_通知_异步_服务
android·笔记·学习
野犬寒鸦1 小时前
从零起步学习并发编程 || 第六章:ReentrantLock与synchronized 的辨析及运用
java·服务器·数据库·后端·学习·算法
wenzhangli71 小时前
ooderA2UI BridgeCode 深度解析:从设计原理到 Trae Solo Skill 实践
java·开发语言·人工智能·开源
HalvmånEver1 小时前
Linux:线程互斥
java·linux·运维