1. RelativeLayout布局的新特性
2. 练习
1. RelativeLayout布局的新特性
2. 练习
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:padding="38dp" //边间距为了美观 6 tools:context="first.pack.MainActivity$PlaceholderFragment" > 7 8 <TextView 9 android:id="@+id/login" 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content" 12 android:gravity="center" //居中 13 android:text="Landing interface" 14 android:textSize="18sp" 15 /> 16 17 <EditText 18 android:id="@+id/usernameText" 19 android:hint="username" //提示字, 一旦打字上去就会消失 20 android:layout_width="wrap_content" 21 android:layout_height="wrap_content" 22 android:layout_below="@+id/login" 23 android:layout_alignParentLeft="true" 24 android:layout_alignParentRight="true" 25 /> 26 27 <EditText 28 android:id="@+id/passwordText" 29 android:hint="password" 30 android:inputType="textPassword" //输入会变成密码星号 31 android:layout_width="wrap_content" 32 android:layout_height="wrap_content" 33 android:layout_below="@+id/usernameText" 34 android:layout_alignLeft="@+id/usernameText" 35 android:layout_alignRight="@+id/usernameText" 36 /> 37 38 <Button 39 android:id="@+id/cancelButton" 40 android:text="Cancel" 41 android:textSize="13sp" 42 android:layout_width="wrap_content" 43 android:layout_height="wrap_content" 44 android:layout_below="@+id/passwordText" 45 android:layout_alignRight="@+id/passwordText"/> 46 47 <Button 48 android:id="@+id/okButton" 49 android:text="Login" 50 android:textSize="13sp" 51 android:layout_width="wrap_content" 52 android:layout_height="wrap_content" 53 android:layout_below="@+id/passwordText" 54 android:layout_toLeftOf="@+id/cancelButton"/> 55 56 </RelativeLayout>