안드로이드 개발 질문/답변
(글 수 45,052)
RelativeLayout 의 내부에 세개의 버튼이있을때
버튼의 height 값을 fill_parent 로설정했을때
다른버튼의 height 값을 fill_parent 의 절반으로 설정하려면 어떻게표현해야되나요
그리고
하나의버튼 오른쪽에 또다른버튼을 놓고
그위에 두개의 버튼중간에 다른버튼을 위치시키고싶은데
어떻게해야되는지를 모르겠습니다
왼쪽버튼의 width 값중간에 위치하도록하면될것같은데
어떤식으로 코딩해야되는지....
조언부탁합니다
2012.07.23 22:03:34
설명듣고 대강 만들어 봤는데 이게 맞나 모르겠네요 ;;
RelativeLayout 안에 LinearLayout 3개 두고 각각 LinearLayout 안에는 android:layout_weight = 1 씩주어서 절반씩 되도록 했습니다.
LinearLayout 위치는 android:layout_alignParentLeft="true", android:layout_alignParentTop="true" 요런식으로 자리를 잡았어요;;
Noizbuster님 말씀대로 빈 레이아웃을 하나 추가해서 Weight를 주었습니다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</LinearLayout>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</LinearLayout>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>




애초에 그리드 레이아웃으로 만들거나
빈 레이아웃을 하나 추가해서 Weight를 같은 값으로 주어도 됩니다.