┌----------------------------------------┐
│☆ ★│
└----------------------------------------┘
이런식으로 두 버튼을 양 사이드 끝에 정렬시키고 싶습니다.
orientation=vertical로 하면 양쪽 정렬이 되는데
☆
★
이런식으로 갈려 버립니다.
orientation=horizontal 로 하면 아예 gravity값이 안들어 갑니다.
어떻게 해야할까요..?
버튼 대신 임의로 textview를 적용했습니다.
적용한 xml 소스입니다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="#ffffff"
android:text="1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#ffffff"
android:text="2" />
</LinearLayout>
</LinearLayout>
frag님 답변 감사드립니다.
일단 두번째 방법이 더 깔끔해 보여서 두 번째 방법으로 처리하였습니다.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:background="#ffffff"
android:text="2" />
</RelativeLayout>
이렇게 처리 하였습니다~!
답변 감사드립니다^^
방법이 2가지가 있겠는데요.
1. 버튼과 버튼 사이에 정렬을 위한 뷰를 놓고 이 뷰의 weight 를 1로 변경한다.
2. LinearLayout 을 RelativeLayout 으로 변경하고 각각의 버튼의 Layout align parent ~ 속성과 Layout center vertical 속성을 변경하여 정렬한다.
개인적으로는 2번 방법의 RelativeLayout 을 추천 드리고 싶네요.