출처: https://3months.tistory.com/307 [Deep Play]

안드로이드/연습

[Android] xml RelativeLayout 2

코딩하는 랄뚜기 2021. 8. 11. 20:55

다른 위젯의 상대적인 위치를 적용할 때의 속성

<?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">
    <Button
        android:id="@+id/stand"
        android:layout_height="150dp"
        android:layout_width="150dp"
        android:layout_margin="10dp"
        android:text="기준 위젯"
        android:layout_centerInParent="true">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="1번"
        android:layout_alignTop="@+id/stand"
        android:layout_toLeftOf="@+id/stand">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="2번"
        android:layout_alignBaseline="@+id/stand"
        android:layout_toLeftOf="@+id/stand">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="3번"
        android:layout_alignBottom="@+id/stand"
        android:layout_toLeftOf="@+id/stand">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="4번"
        android:layout_above="@+id/stand"
        android:layout_alignLeft="@+id/stand">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="5번"
        android:layout_below="@+id/stand"
        android:layout_alignRight="@+id/stand">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="60dp"
        android:text="6번"
        android:layout_above="@+id/stand"
        android:layout_toRightOf="@+id/stand">
    </Button>


</RelativeLayout>

실행화면

'안드로이드 > 연습' 카테고리의 다른 글

[Android] 시간예약  (0) 2021.08.18
[Android] 테이블레이아웃 계산기  (0) 2021.08.18
[Android] RelativeLayout 속성  (0) 2021.08.11
[Android] xml layout_weight  (0) 2021.08.11
[Android] 단순한 계산기  (0) 2021.08.10