프로그래밍/Android

안드로이드 relative layout 상대레이아웃 컴포넌트들이 겹칠 때

Jay Tech 2017. 1. 3. 12:31
반응형

화면배치에서 예를 들어 텍스트뷰와 버튼이 겹쳐지는 상황




이 상황에서 xml파일에서 텍스트뷰의 상대 레이아웃 크기를 조절한다 

<?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="match_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentTop="true"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textView"
android:background="#0e13ff"
android:layout_below="@+id/button"
android:layout_above="@+id/button2"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_alignParentBottom="true"/>

</RelativeLayout>
android:layout_below="@+id/button"
android:layout_above="@+id/button2"


밑에 2줄로 상대레이아웃을 설정하는데 

below속성은 첫번째 버튼 밑에서 부터 시작되는 것이고

above속성은 두번째 버튼 바로 위까지 영역이 설정되는 것이다



반응형