安卓布局


#一、
安卓的布局,RelativeLayout配LinearLayout
android:background=”@drawable/edit_shape”用xml文件来实现圆角

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#377EB4" >

<LinearLayout
android:id="@+id/username"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="horizontal" >

<EditText
android:id="@+id/et_name"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/edit_shape"
android:ems="10"
android:inputType="textPersonName" >

<requestFocus />
</EditText>
</LinearLayout>

<LinearLayout
android:id="@+id/password"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/username"
android:layout_below="@+id/username"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >

<EditText
android:id="@+id/et_psw"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/edit_shape"
android:ems="10"
android:inputType="textPassword" />
</LinearLayout>

<LinearLayout
android:id="@+id/log_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/password"
android:layout_below="@+id/password"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >

<Button
android:id="@+id/login_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:text="登陆"
android:textColor="#ffffff" />
</LinearLayout>

<RelativeLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/log_btn"
android:layout_below="@+id/log_btn"
android:layout_marginTop="15dp"
android:background="#377EB4" >

<TextView
android:id="@+id/for_psw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="25dp"
android:text="忘记密码?"
android:textColor="#FFFFFF" />

<TextView
android:id="@+id/qui_reg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="22dp"
android:layout_toLeftOf="@+id/for_psw"
android:typeface="monospace"
android:text="快速注册"
android:textColor="#FFFFFF" />

</RelativeLayout>

</RelativeLayout>

#二、设置字体

1
2
3
typeFace = Typeface.createFromAsset(getAssets(), "fonts/01.ttf");
fp = (TextView) findViewById(R.id.for_psw);
fp.setTypeface(typeFace);

#三、注册页面

1
2
<activity android:name="com.example.videotest.Res_View" >
</activity>