728x90
반응형
핵심 ->> id를 정해놓아야함
android:layout_toRightOf="@id/기준잡는컴포넌트ID"
android:layout_toLeftOf="@id/기준잡는컴포넌트ID"
android:layout_below="@id/기준잡는컴포넌트ID"
android:layout_above="@id/기준잡는컴포넌트ID"
<?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">
<TextView
android:id="@+id/view1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#f23204"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/view2"
android:layout_toRightOf="@id/view1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#FFEB3B"/>
<TextView
android:id="@+id/view3"
android:layout_below="@id/view1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#3F51B5"/>
<TextView
android:id="@+id/view4"
android:layout_above="@id/view1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#4CAF50"/>
<TextView
android:id="@+id/view5"
android:layout_toLeftOf="@id/view1"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#673AB7"/>
</RelativeLayout>
728x90
반응형
'모바일 > Android View & Layout' 카테고리의 다른 글
[Android] padding & margin (0) | 2021.04.19 |
---|---|
[Android] RelativeLayout 실습 (0) | 2021.04.18 |
[Android] RelativeLayout (부모 기준) (0) | 2021.04.18 |
[Android] LinearLayout 예제 (0) | 2021.04.16 |
[Android] LinearLayout (2) gravity, layout_weight, weightSum (0) | 2021.04.16 |
댓글