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

안드로이드/연습

[Android] RelativeLayout 속성

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

RelativeLayout은 위와 같이 7가지 속성이 있다

<?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:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="위쪽"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="좌측"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="중앙"
        android:layout_centerInParent="true">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="우측"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true">
    </Button>
    <Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="아래"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true">
    </Button>


</RelativeLayout>

 

실행화면