Android实现简单登录界面

LoginActivity

 1 package com.example.myapplication;
 2 
 3 import android.os.Bundle;
 4 import android.view.View;
 5 
 6 import androidx.annotation.Nullable;
 7 import androidx.appcompat.app.AppCompatActivity;
 8 
 9 public class LoginActivity extends AppCompatActivity implements View.OnClickListener{
10     @Override
11     protected void onCreate(@Nullable Bundle savedInstanceState) {
12         super.onCreate(savedInstanceState);
13         setContentView(R.layout.activity_login);
14 
15 
16 
17     }
18 
19     @Override
20     public void onClick(View v) {
21 
22     }
23 }

Activity_login

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:layout_centerInParent="true"
 6     >
 7     <LinearLayout
 8         android:id="@+id/ll_input"
 9         android:layout_centerInParent="true"
10         android:layout_width="match_parent"
11         android:layout_height="wrap_content"
12         android:orientation="vertical">
13         <LinearLayout
14             android:layout_width="match_parent"
15             android:layout_height="wrap_content"
16             android:orientation="horizontal"
17             >
18             <TextView
19                 android:layout_width="wrap_content"
20                 android:layout_height="wrap_content"
21                 android:width="50dp"
22                 android:text="账号"
23                 >
24             </TextView>
25             <EditText
26                 android:layout_width="match_parent"
27                 android:layout_height="wrap_content"
28                 android:hint="请输入账号" />
29         </LinearLayout>
30         <LinearLayout
31             android:layout_width="match_parent"
32             android:layout_height="wrap_content"
33             android:orientation="horizontal"
34             >
35             <TextView
36                 android:layout_width="wrap_content"
37                 android:layout_height="wrap_content"
38                 android:width="50dp"
39                 android:text="密码"
40                 >
41             </TextView>
42 
43             <EditText
44                 android:layout_width="match_parent"
45                 android:layout_height="wrap_content"
46                 android:hint="请输入密码" />
47         </LinearLayout>
48         <Button
49             android:layout_width="match_parent"
50             android:layout_height="wrap_content"
51             android:text="登录"
52             />
53         <LinearLayout
54             android:layout_width="match_parent"
55             android:layout_height="wrap_content"
56             android:orientation="horizontal"
57             >
58             <Button
59                 android:layout_width="0dp"
60                 android:layout_height="wrap_content"
61                 android:layout_weight="1"
62                 android:text="注册"
63                 />
64             <Button
65                 android:layout_width="0dp"
66                 android:layout_height="wrap_content"
67                 android:layout_weight="1"
68                 android:text="忘记密码"
69                 />
70         </LinearLayout>
71     </LinearLayout>
72     <LinearLayout
73         android:layout_width="match_parent"
74         android:gravity="center"
75         android:orientation="vertical"
76         android:layout_height="match_parent"
77         android:layout_above="@id/ll_input"
78         >
79         <ImageView
80             android:layout_width="wrap_content"
81             android:layout_height="wrap_content"
82             android:src="@android:drawable/btn_star_big_on"
83             ></ImageView>
84     </LinearLayout>
85     <TextView
86         android:layout_width="wrap_content"
87         android:layout_height="wrap_content"
88         android:layout_alignParentBottom="true"
89         android:layout_centerHorizontal="true"
90         android:text="最终解释权归本公司所有"
91         >
92     </TextView>
93 </RelativeLayout>

效果图

Android实现简单登录界面

 

上一篇:Activity启动模式singleTask模式


下一篇:【转】Android程序右上角不显示3个点的菜单