반응형

이번 시간에는 RelativeLayout의 정리한 자료를 바탕으로 앱을 만들어보았다.

아래 게시물의 내용이 포함된 앱을 만들었다.

 

[안드로이드 스튜디오 정리#1] Layout

이 게시물은 다음 링크를 참조하여 학습했습니다. 안드로이드 레이아웃 (Android Layout) 1. 안드로이드 Layout 클래스 안드로이드 Layout 클래스는 View 위젯들을 화면에 배치하는 과정에서, 위젯의 위치

seminzzang.tistory.com

 

 

[안드로이드 스튜디오 정리#1-2] RelativeLayout

이 게시물은 다음 링크를 참조하여 학습했습니다. 안드로이드 렐러티브레이아웃. (Android RelativeLayout) 1. 안드로이드 RelativeLayout 클래스. [안드로이드 리니어레이아웃. (Android LinearLayout)]에서 설명.

seminzzang.tistory.com

화면만 구성하였기에, 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]에 다 정리되어 있는 내용이라 설명은 생략하겠다.

실행화면은 다음과 같이 출력된다.

RelativeLayout - GameConsole

반응형

+ Recent posts