代码和注解如下:

运行代码时要删除注释

注意文件名不能有大写

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout
 3     xmlns:android="http://schemas.android.com/apk/res/android"
 4     android:layout_width="match_parent"  //没有总父级,这里就是手机总屏幕
 5     android:layout_height="match_parent"
 6     android:background="@mipmap/img_20191105_072932"  //在mipmap下添加照片,添加的路径取决于手机的像素类型,具体可见【转】Android hdpi ldpi mdpi xhdpi xxhdpi适配详解 - 神奇的旋风 - 博客园 (cnblogs.com)
 7     android:orientation="vertical"  //大框架为相对布局,垂直为主要方向
 8     >
 9 
10     <LinearLayout
11         android:layout_width="match_parent"  //宽度继承父级布局(相对布局,即总宽度)
12         android:layout_height="wrap_content"
13         android:layout_marginTop="50dp"  //次级的线性布局,让大体内容距离顶部50dp
14         android:padding="30dp"  //边框距离30dp
15         android:orientation="vertical">
16         <TextView
17             android:drawableLeft="@mipmap/ic_launcher"  //调用图片,原本为白色企鹅的图片,这里以系统自带的小安卓照片为准
18             android:layout_width="wrap_content"
19             android:layout_height="wrap_content"
20             android:textSize="40sp"
21             android:text="QQ"/>
22 
23         <EditText
24             android:layout_width="match_parent"
25             android:hint="QQ号码/手机号/邮箱"
26             android:textColorHint="@color/white"
27             android:layout_height="match_parent"/>
28 
29         <EditText
30             android:layout_marginTop="30dp"
31             android:layout_width="match_parent"
32             android:hint="密码"
33             android:textColorHint="@color/white"
34             android:layout_height="match_parent"/>
35 
36         <Button
37             android:layout_width="match_parent"
38             android:layout_height="wrap_content"
39             android:text="登录"
40             android:textSize="20sp"
41             android:background="#00aaff"/>
42 
43         <RelativeLayout
44             android:layout_width="match_parent"
45             android:layout_height="wrap_content">
46 
47             <TextView
48                 android:layout_width="wrap_content"
49                 android:layout_height="wrap_content"
50                 android:text="忘记密码"
51                 android:textColor="#00aaff"
52                 android:textSize="16sp"/>
53 
54             <TextView
55                 android:layout_width="wrap_content"
56                 android:layout_height="wrap_content"
57                 android:text="新用户注册"
58                 android:textColor="#00aaff"
59                 android:textSize="16sp"
60                 android:layout_alignParentRight="true"/>  //靠右对齐
61 
62         </RelativeLayout>
63 
64     </LinearLayout>
65 
66     <TextView
67         android:layout_width="wrap_content"
68         android:layout_height="wrap_content"
69         android:layout_alignParentBottom="true"  //置于父级框架底部,这里是相对布局
70         android:layout_centerHorizontal="true"  //水平居中
71         android:layout_marginBottom="20dp"  //距离底部20dp
72         android:text="登录即代表阅读并同意服务条款"
73         android:textColor="#00aaff"
74         android:textSize="20sp"
75         android:id="@+id/a">
76     </TextView>
77 </RelativeLayout>

效果图如下;

 

 

posted on 2021-07-15 16:56  EndlessShw  阅读(210)  评论(0编辑  收藏  举报