안드로이드 개발 질문/답변
(글 수 45,052)
첨부한 이미지 처럼 오른쪽 영역에 고정 영역을 잡고 왼쪽 영역은
나머지 영역만큼만 줄려고 합니다.
레이아웃은 RelativeLayout로 잡았구요.
RelativeLayout로 한 이유는 맨 오른쪽 영역을 고정으로 줄려고 그랬습니다.
android:layout_alignParentRight="true"로 하니까 맨 오른쪽으로 붙더군요.
그래서 왼쪽 영역을 붙였는데 왼쪽 레이아웃에 android:layout_width="fill_parent"를 주니
오른쪽 고정영역까지 잡아 먹습니다.-_-'
오른쪽은 고정으로 해주고 나머지만 사용할수 있는 방법이 없을까여?
도움 부탁드립니다.
2011.11.15 18:56:41
그런 의도라면 LinearLayout 이 낫습니다.
왼쪽것을 width 를 0으로 주고 weight 를 1로 주고.. 오른쪽을 고정 길이를 주면(wrap_content 나 100dip나..)
원하는 모양이 나올거에요.
2011.11.15 22:44:20
xml을 전개할때 원패스 방식으로 전개하니
오른쪽 레이아웃을 먼저 배치하시고
왼쪽 레이아웃은 layout_toLeftOf="@id/오른쪽 레이아웃 id"
처럼 붙이시면 됩니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/linearLayout1"
android:background="#FFFF0000"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>




머릿속으로만 그려봅니다.
레이아웃을 잡을때 오른쪽영역(A)을 먼저 잡으시고(android:layout_alignParentRight="true")
왼쪽 영역(B)을 잡을때 android:layout_width="fill_parent"를 주고
A의 왼쪽에 있다라는 선언(layout_toLeftOf )을 해주시면 되지 않을까요?