安卓学习 之 模拟登录界面

经过昨天一天的调试,今天终于可以正常模拟了,由于电脑的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>  //线性布局结束
相关推荐
CheerWWW3 分钟前
C++学习笔记——函数指针、Lambda表达式、谨慎使用using namespace std、命名空间
c++·笔记·学习
@小博的博客12 分钟前
【Linux探索学习】第六弹:操作系统的概念及冯诺依曼体系结构
linux·学习
Ivanqhz13 分钟前
LLVM IR 转 SMT公式
java·开发语言
一个心烑18 分钟前
奖项届定获取方式
java
小红的布丁18 分钟前
Reactor 模型详解:单 Reactor、主从 Reactor 与 Netty 思想
android·java·开发语言
talen_hx29620 分钟前
《零基础入门Spark》学习笔记 Day 14
大数据·笔记·学习·spark
Clarence Liu20 分钟前
langchain源码研究 - deepagents设计思想学习
人工智能·驱动开发·学习·langchain
Shadow(⊙o⊙)22 分钟前
static与extern使用
c语言·学习
weixin_7042660524 分钟前
redis 的集群
java·数据库·redis
被摘下的星星26 分钟前
Java的类加载
java·开发语言