新建一个文件“practice1.xml”
编写代码如下:
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:orientation="vertical" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent"> 6 <EditText 7 android:layout_width="match_parent" 8 android:layout_height="wrap_content" 9 android:hint="To"/> 10 <EditText 11 android:layout_width="match_parent" 12 android:layout_height="wrap_content" 13 android:hint="Subject"/> 14 <EditText 15 android:layout_width="match_parent" 16 android:layout_height="wrap_content" 17 android:hint="Message" 18 android:layout_weight="1" 19 android:gravity="top|left"/> 20 <LinearLayout 21 android:layout_width="match_parent" 22 android:layout_height="wrap_content"> 23 <Button 24 android:layout_width="0dp" 25 android:layout_height="wrap_content" 26 android:id="@+id/button" 27 android:text="Reset" 28 android:layout_weight="1" 29 android:textAllCaps="false" 30 android:textSize="20sp"/> 31 <Button 32 android:layout_width="0dp" 33 android:layout_height="wrap_content" 34 android:id="@+id/button2" 35 android:text="Send" 36 android:layout_weight="1" 37 android:textAllCaps="false" 38 android:textSize="20sp"/> 39 </LinearLayout> 40 </LinearLayout>
运行模拟器效果如下图: