반응형
Coding 카테고리의 이번 게시물부터는 유튜브 강의가 아닌 내가 정리한 이론을 베이스로 공부해보려 한다.
아래 게시물들의 내용을 최대한 담아 간단한 앱을 만들어 보았다.
화면만 구성하였기에, 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
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:weightSum="7"
>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="5dp"
android:gravity="center"
android:text="RAINBOW"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#E91E63"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="RED"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#FF9800"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="ORANGE"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#FFEB3B"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="YELLOW"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#4CAF50"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="GREEN"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#3F51B5"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="BLUE"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#673AB7"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="NAVY"
android:textSize="20sp"/>
<TextView
android:layout_width="100dp"
android:layout_height="0dp"
android:background="#9C27B0"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="5dp"
android:gravity="center"
android:text="PURPLE"
android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
|
cs |
LinearLayout안에 LinearLayout을 사용하여 가운데정렬을 구현하였고,
weightSum을 7로 주고 무지개의 색상들의 weight를 1로 줘서 7개의 색이 정확히 7등분 되도록 구현했다.
textSize의 기본값이 작은것 같아서 20sp로 올리고 적당히 margin과 padding을 줘서 다음 앱 화면을 구현했다.
반응형
'Legacy' 카테고리의 다른 글
[안드로이드 스튜디오 독학#10] FrameLayout (0) | 2021.01.14 |
---|---|
[안드로이드 스튜디오 독학#9] RelativeLayout (0) | 2021.01.13 |
[안드로이드 스튜디오 정리#1-7] ListView, GridView (0) | 2021.01.13 |
[안드로이드 스튜디오 정리#1-6] ConstraintLayout (2) | 2021.01.12 |
[안드로이드 스튜디오 정리#1-5] DrawerLayout (0) | 2021.01.12 |