안드로이드 어플리케이션에서 가장 많이 활용하는 레이아웃이다. 상대적인 대상과의 위치를 지정할 수 있다.

 

 예제는 간단하다. RelativeLayout 베이스에서 화면의 모든 부분에 시계방향으로 버튼을 위치하면 된다. 추후 디자인적인 측면의 작업을 빠르게 하기 위한 연습 과정이다.



 



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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1시버튼"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="3시버튼"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="5시버튼"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="6시버튼"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"/>
 
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="7시버튼"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="9시버튼"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="11시버튼"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="12시버튼"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"/>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="센터버튼"
        android:layout_centerInParent="true"/>
 
</RelativeLayout>
cs


+ Recent posts