1.首先是布局檔案XML檔案,不解釋直接上 1>主介面 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:background="@drawable/back_groud" > 6 7 <LinearLayout 8 android:layout_width="match_parent" 9 android:layout_height="wrap_content" 10 android:layout_above="@+id/login_data_layout" 11 android:layout_marginBottom="30dp" 12 android:gravity="center" 13 android:orientation="horizontal" > 14 15 <ImageView 16 android:layout_width="wrap_content" 17 android:layout_height="wrap_content" 18 android:src="@drawable/logo" /> 19 20 </LinearLayout> 21 22 <LinearLayout 23 android:id="@+id/login_data_layout" 24 android:layout_width="match_parent" 25 android:layout_height="wrap_content" 26 android:layout_centerInParent="true" 27 android:background="@drawable/logindata_back_groud" 28 android:orientation="vertical" > 29 30 <LinearLayout 31 android:id="@+id/username_layout" 32 android:layout_width="match_parent" 33 android:layout_height="match_parent" 34 android:layout_marginLeft="10dp" 35 android:layout_marginRight="10dp" 36 android:layout_weight="1" 37 android:gravity="center_vertical" 38 android:orientation="horizontal" > 39 40 <TextView 41 android:layout_width="wrap_content" 42 android:layout_height="wrap_content" 43 android:layout_gravity="center_vertical" 44 android:layout_marginLeft="15dp" 45 android:text="賬 號" 46 android:textColor="#b3b3b3" 47 android:textSize="16dp" /> 48 49 <EditText 50 android:id="@+id/login_edit_userName" 51 android:layout_width="match_parent" 52 android:layout_height="wrap_content" 53 android:layout_gravity="center_vertical" 54 android:layout_marginLeft="20dp" 55 android:layout_marginRight="20dp" 56 android:layout_weight="1" 57 android:background="@null" 58 android:singleLine="true" /> 59 60 <RelativeLayout 61 android:layout_width="wrap_content" 62 android:layout_height="wrap_content" 63 android:layout_weight="2.5" > 64 65 <Button 66 android:id="@+id/down_but" 67 android:layout_width="24dp" 68 android:layout_height="24dp" 69 android:layout_alignParentRight="true" 70 android:layout_marginRight="8dp" 71 android:background="@drawable/down_img" /> 72 </RelativeLayout> 73 </LinearLayout> 74 75 <LinearLayout 76 android:layout_width="match_parent" 77 android:layout_height="match_parent" 78 android:layout_marginLeft="25dp" 79 android:layout_marginRight="10dp" 80 android:layout_weight="1" 81 android:gravity="center_vertical" 82 android:orientation="horizontal" > 83 84 <TextView 85 android:layout_width="wrap_content" 86 android:layout_height="wrap_content" 87 android:layout_gravity="center_vertical" 88 android:text="密 碼" 89 android:textColor="#b3b3b3" 90 android:textSize="16dp" /> 91 92 <EditText 93 android:id="@+id/login_edit_password" 94 android:layout_width="match_parent" 95 android:layout_height="wrap_content" 96 android:layout_gravity="center_vertical" 97 android:layout_marginLeft="20dp" 98 android:layout_marginRight="20dp" 99 android:background="@null"100 android:inputType="textPassword"101 android:singleLine="true" />102 </LinearLayout>103 </LinearLayout>104 105 <Button106 android:id="@+id/login_but_landing"107 android:layout_width="match_parent"108 android:layout_height="wrap_content"109 android:layout_below="@+id/login_data_layout"110 android:layout_marginTop="30dp"111 android:background="@drawable/login_but_bg"112 android:text="登 錄"113 android:textColor="#ffffff"114 android:textSize="18dp" />115 116 </RelativeLayout> 2>浮動視窗介面及其子介面 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" 6 android:gravity="center_horizontal" > 7 8 <ListView 9 android:layout_width="match_parent"10 android:layout_height="wrap_content"11 android:id="@+id/list"12 android:background="@drawable/list_backgroud"13 ></ListView>14 15 16 </LinearLayout> 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" > 5 6 <RelativeLayout 7 android:layout_width="wrap_content" 8 android:layout_height="40dp" 9 android:gravity="center_vertical" >10 11 <Button12 android:id="@+id/del_but"13 android:layout_width="25dp"14 android:layout_height="25dp"15 android:layout_alignParentRight="true"16 android:layout_marginRight="15dp"17 android:background="@drawable/del_but_bg" />18 19 <TextView20 android:id="@+id/tv"21 android:layout_width="wrap_content"22 android:layout_height="wrap_content"23 android:layout_alignParentLeft="true"24 android:layout_marginLeft="15dp"25 android:layout_toLeftOf="@+id/del_but"26 android:textSize="16dp" />27 </RelativeLayout>28 29 </LinearLayout>