Bước 1: Mở file res->values ->strings.xml
1
2
3
4
5
6
7
8
9
10
| < resources > < string name = "app_name" >RelativeLayout</ string > < string name = "etHin" >Enter char</ string > < string name = "bt1" >Button 1</ string > < string name = "bt2" >Button 2</ string > < string name = "bt3" >Button 3</ string > < string name = "bt4" >Button 4</ string > </ resources > |
Bước 2: Mở file res-> layout ->layout_main.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
| <? xml version = "1.0" encoding = "utf-8" ?> android:layout_width = "match_parent" android:layout_height = "match_parent" android:paddingLeft = "10dp" android:paddingRight = "10dp" > <!-- thuoc tinh padding, paddingLeft, paddingRight, paddingTop, paddingBottom --> <!-- de can chinh cac phan tu con cua no cach le trai le phai tren duoi 1 khoang --> <!-- bao nhieu dp --> <!-- thuoc tinh layout_marginLeft, layout_marginTop, layout_marginRight, layout_marginBottom --> <!-- de cach "bien" trai, tren, phai, duoi mot khoang tuy chinh --> < EditText android:id = "@+id/et1" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:layout_marginTop = "50dp" android:hint = "@string/etHin" /> <!-- thuoc tinh layout_alignParentRight, layout_alignParentBottom, layout_alignParentTop, layout_alignParentLeft --> <!-- de dat View Con o phai cung, duoi cung, tren cung, trai cung cua cha no --> <!-- thuoc tinh layout_below, layout_above, layout_toLeftOf, layout_toRightOf --> <!-- de dat 1 View o duoi, tren, ben trai, ben phai cua 1 View khac trong vi du --> <!-- minh xac dinh bang id --> < Button android:id = "@+id/bt1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_alignParentRight = "true" android:layout_below = "@+id/et1" android:text = "@string/bt1" /> < Button android:id = "@+id/bt2" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_below = "@+id/et1" android:layout_marginRight = "20dp" android:layout_toLeftOf = "@+id/bt1" android:text = "@string/bt2" /> < EditText android:id = "@+id/et2" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:layout_alignParentBottom = "true" android:layout_marginBottom = "50dp" android:hint = "@string/etHin" /> < Button android:id = "@+id/bt3" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_above = "@+id/et2" android:text = "@string/bt3" /> < Button android:id = "@+id/bt4" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_centerHorizontal = "true" android:layout_centerVertical = "true" android:text = "@string/bt4" /> </ RelativeLayout > |
Kết quả thực hiện vẽ giao diện
0 nhận xét:
Đăng nhận xét