自己写的登录界面

代码如下:

这是string.xml

 1 <resources>
 2     <string name="app_name">TestLogin</string>
 3     <string name="app_login">用户注册</string>
 4     <string name="app_userName">用户名:</string>
 5     <string name="app_userNameHint">请输入用户名</string>
 6     <string name="app_password">密码:</string>
 7     <string name="app_inputpassword">请输入密码</string>
 8     <string name="app_userGender">性别:</string>
 9     <string name="app_man"></string>
10     <string name="app_woman"></string>
11     <string name="app_userHobby">兴趣:</string>
12     <string name="app_userHobby1">跑步</string>
13     <string name="app_userHobby2">上网</string>
14     <string name="app_userHobby3">读书</string>
15     <string name="app_register">注册</string>
16 </resources>

register.xml

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3     xmlns:tools="http://schemas.android.com/tools"
  4     android:layout_width="match_parent"
  5     android:layout_height="match_parent"
  6     android:orientation="vertical"
  7     android:background="@drawable/picture"
  8     tools:context="com.example.administrator.testlogin.MainActivity">
  9 
 10     <LinearLayout
 11         android:layout_width="match_parent"
 12         android:layout_height="wrap_content"
 13         android:layout_marginTop="20dp"
 14         android:gravity="center">
 15 
 16         <TextView
 17             android:layout_width="wrap_content"
 18             android:layout_height="wrap_content"
 19             android:text="@string/app_login"
 20             android:textSize="30sp" />
 21     </LinearLayout>
 22 
 23     <RelativeLayout
 24         android:layout_width="match_parent"
 25         android:layout_height="wrap_content">
 26 
 27         <TextView
 28             android:id="@+id/user"
 29             android:layout_width="wrap_content"
 30             android:layout_height="wrap_content"
 31             android:layout_marginTop="20dp"
 32             android:text="@string/app_userName"
 33             android:textSize="25sp" />
 34 
 35         <EditText
 36             android:id="@+id/userName"
 37             android:layout_width="match_parent"
 38             android:layout_height="wrap_content"
 39             android:layout_alignBaseline="@+id/user"
 40             android:layout_toRightOf="@+id/user"
 41             android:hint="@string/app_userNameHint"
 42             android:textSize="20sp" />
 43 
 44         <TextView
 45             android:id="@+id/textView"
 46             android:layout_width="wrap_content"
 47             android:layout_height="wrap_content"
 48             android:layout_below="@+id/userName"
 49             android:layout_marginTop="20dp"
 50             android:text="@string/app_password"
 51             android:textSize="25sp"
 52             />
 53 
 54         <EditText
 55             android:id="@+id/password"
 56             android:layout_width="match_parent"
 57             android:layout_height="wrap_content"
 58             android:layout_alignBaseline="@+id/textView"
 59             android:layout_alignLeft="@+id/userName"
 60             android:layout_below="@+id/userName"
 61             android:layout_toRightOf="@+id/textView"
 62             android:hint="@string/app_inputpassword"
 63             android:textSize="20sp"
 64             android:inputType="textPassword"/>
 65 
 66 
 67     </RelativeLayout>
 68 <!--使性别和两个RadioButton对齐,用了android:layout_gravity="center_vertical"-->
 69     <LinearLayout
 70         android:layout_width="match_parent"
 71         android:layout_height="wrap_content"
 72         android:layout_marginTop="20dp"
 73         android:layout_gravity="center_vertical"
 74 
 75         >
 76 
 77         <TextView
 78             android:id="@+id/sex"
 79             android:layout_width="wrap_content"
 80             android:layout_height="wrap_content"
 81             android:text="@string/app_userGender"
 82             android:textSize="25sp" />
 83 
 84         <RadioGroup
 85             android:layout_marginLeft="20dp"
 86             android:layout_width="match_parent"
 87             android:layout_height="wrap_content"
 88             android:orientation="horizontal">
 89 
 90             <RadioButton
 91 
 92                 android:id="@+id/nan"
 93                 android:layout_width="wrap_content"
 94                 android:layout_height="wrap_content"
 95                 android:layout_weight="1"
 96                 android:text="@string/app_man"
 97                 android:textSize="20sp" />
 98 
 99             <RadioButton
100                 android:id="@+id/nv"
101                 android:layout_width="wrap_content"
102                 android:layout_height="wrap_content"
103                 android:layout_weight="1"
104                 android:text="@string/app_woman"
105                 android:textSize="20sp" />
106         </RadioGroup>
107     </LinearLayout>
108     <LinearLayout
109         android:layout_marginTop="20dp"
110         android:layout_width="match_parent"
111         android:layout_height="wrap_content"
112         android:layout_gravity="center_vertical">
113         <TextView
114             android:layout_width="wrap_content"
115             android:layout_height="wrap_content"
116             android:text="@string/app_userHobby"
117             android:textSize="25sp"/>
118         <CheckBox
119             android:layout_width="wrap_content"
120             android:layout_height="wrap_content"
121             android:text="@string/app_userHobby1"
122             android:textSize="20sp"
123             android:layout_weight="1"/>
124         <CheckBox
125             android:layout_width="wrap_content"
126             android:layout_height="wrap_content"
127             android:text="@string/app_userHobby2"
128             android:textSize="20sp"
129             android:layout_weight="1"/>
130         <CheckBox
131             android:layout_width="wrap_content"
132             android:layout_height="wrap_content"
133             android:text="@string/app_userHobby3"
134             android:textSize="20sp"
135             android:layout_weight="1"/>
136     </LinearLayout>
137     <Button
138         android:layout_marginTop="20dp"
139         android:layout_width="match_parent"
140         android:layout_height="wrap_content"
141         android:text="@string/app_register"
142         android:textSize="20sp"
143         android:gravity="center_horizontal"
144         android:theme="@style/Base.Widget.AppCompat.ImageButton" />
145 
146 </LinearLayout>

 

posted @ 2020-02-05 23:00  东功  阅读(203)  评论(0编辑  收藏  举报