반응형
이번 시간에는 RelativeLayout의 정리한 자료를 바탕으로 앱을 만들어보았다.
아래 게시물의 내용이 포함된 앱을 만들었다.
화면만 구성하였기에, 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/game"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GAME CONSOLE"
android:textSize="15sp"
android:gravity="center"
android:paddingTop="10sp"
android:paddingBottom="10sp"
android:background="#BBBBBB"
/>
<Button
android:id="@+id/btn_prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PREV"
android:layout_marginLeft="5dp"
android:layout_below="@id/game"
/>
<Button
android:id="@+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NEXT"
android:layout_marginRight="5dp"
android:layout_below="@id/game"
android:layout_alignParentRight="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GAME1"
android:background="#eeeeee"
android:layout_toRightOf="@id/btn_prev"
android:layout_toLeftOf="@+id/btn_next"
android:layout_alignTop="@+id/btn_next"
android:layout_alignBottom="@id/btn_next"
android:layout_margin="5dp"
android:gravity="center"
android:textSize="20dp"
/>
<TextView
android:id="@+id/game_over"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginLeft="30dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:text="GAME OVER"
android:textSize="30dp"
android:gravity="center"
android:background="#000000"
/>
<Button
android:id="@+id/btn_up"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="U"
android:layout_below="@+id/game_over"
android:layout_alignLeft="@+id/btn_down"
/>
<Button
android:id="@+id/btn_down"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="D"
android:layout_margin="5dp"
android:layout_below="@id/btn_up"
android:layout_toLeftOf="@+id/btn_right"
/>
<Button
android:id="@+id/btn_left"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="L"
android:layout_margin="5dp"
android:layout_below="@+id/btn_up"
android:layout_toLeftOf="@id/btn_down"
/>
<Button
android:id="@+id/btn_right"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="R"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:layout_below="@id/btn_up"
/>
<Button
android:id="@+id/btn_A"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_alignTop="@id/btn_left"
/>
<Button
android:id="@+id/btn_B"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="2"
android:layout_toRightOf="@+id/btn_A"
android:layout_marginLeft="10dp"
android:layout_alignTop="@id/btn_left"
/>
<Button
android:id="@+id/btn_C"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="3"
android:layout_toRightOf="@+id/btn_B"
android:layout_marginLeft="10dp"
android:layout_alignTop="@id/btn_left"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CLOSE"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
|
cs |
코드가 비교적 긴데, 위에 링크로 걸어둔 [안드로이드 스튜디오 정리 #1-2]에 다 정리되어 있는 내용이라 설명은 생략하겠다.
실행화면은 다음과 같이 출력된다.
반응형
'Legacy' 카테고리의 다른 글
[안드로이드 스튜디오 독학#11] TableLayout (0) | 2021.01.14 |
---|---|
[안드로이드 스튜디오 독학#10] FrameLayout (0) | 2021.01.14 |
[안드로이드 스튜디오 독학#8] LinearLayout (0) | 2021.01.13 |
[안드로이드 스튜디오 정리#1-7] ListView, GridView (0) | 2021.01.13 |
[안드로이드 스튜디오 정리#1-6] ConstraintLayout (2) | 2021.01.12 |