그런데 문제는 버튼들의 text가 다를 경우 layout_weight가 소용이 없네요.
세개의 버튼이 있고 각 버튼에 표시되는 text의 길이차이가 있는 경우
이 세개의 버튼 가로 크기를 같게 할 방법 없을까요
동일한 질문에 역시나 layout_weight를 사용하라는 답변만 검색되네요
아래 답변 감사하고요..
질문 내용을 조금 수정할게요..
어떤 해상도에서도 가로로 꽉차게 같은 크기로 버튼 3개를 놓고 싶습니다.
(가로 세로 회전시에도 가로로 꽉차도록..)
아래 답변처럼 하면 가로 회전만 시켜도 사이즈가 맞질 않게되죠
답변감사합니다...
버전 차이인지 뭔지..첨부하신 그림을 보니 분명 버튼들의 가로 크기가 동일한데
저의 경우 레이아웃 속성이야 당연 수평이고요 layout_weight를 동일하게 주어도 버튼별 가로 크기가
다르게 나옵니다.
보여주신 그림처럼 무지한 텍스트를 버튼에 표시하려는건 아니고요..^^
간단히 Yes No Cancel 이렇게만 표시한다고 예를 들어도 버튼의 크기가 다르게 나오네요
참고로 사용한 xml 입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_width="match_parent"
android:orientation="horizontal">
<Button android:layout_width="wrap_content" android:id="@+id/button1"
android:text="Yes" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:layout_width="wrap_content" android:id="@+id/button2"
android:text="No" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
<Button android:text="Cancel" android:id="@+id/button3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>




layout_width 의 폭을 같이 지정하심이..
dp 단위로 지정하면 일부 해상도의 단말기를 제외하고는 동일한 비율로 적용되니 원하신는 데로 될 듯 하네요..
기본적인 세로화면 기준으로 가로폭이 320dp 니까 원하는 크기대로 나누어 할당하면 될 듯 하네요.