2012-05-05 3 views
0

dp를 지정하지 않고 라디오 버튼을 자동으로 정렬하려면 어떻게해야합니까?버튼을 자동으로 정렬하는 방법

아래 예제에서는 라디오 버튼 너비 80 및 높이 70이 설정되어 있습니다. 대신 fill_parent 또는 wrap_content처럼이 작업을 수행하려고합니다. 어떻게해야합니까?

<RadioGroup android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:checkedButton="@+id/allcontacts" 
     android:id="@+id/contactgroup"> 
     <RadioButton android:id="@+id/allcontacts" 
     android:width="80dip" 
     android:height="70dip"/> 

     <RadioButton android:id="@+id/categories" 
     android:width="80dip" android:height="70dip" /> 

     <RadioButton android:id="@+id/favourites" 
     android:width="80dip" android:height="70dip" /> 
+0

고정 크기를 적용하는 대신 'wrap_content'를 적용하십시오. – RobinHood

+2

그냥 "정렬하고 싶다"는 말 대신 ... 어떻게 정렬하고 싶은지 말하십시오 ... – JoxTraex

+0

나는이 모든 버튼을 equel 간격으로 수평 정렬하고 싶습니다. dp에서 높이와 너비를 지정하지 않고 이걸 원합니다. – Naruto

답변

1

match_parent의 layout_width로 LinearLayout (가로)의 버튼을 줄 바꿈하십시오.

각 버튼에 대해 layout_height를 wrap_content로 설정하고 layout_width를 0dp로 설정하고 layout_weight를 1로 설정하면 모두 동일한 크기가됩니다.

0

단추 주위를 선형 선형으로 감 쌉니다. 필요할 경우 패딩을 사용하여 정확한 위치를 조정할 수 있습니다.

+0

그래서,이 버튼을 lenear 레이아웃에 넣으시겠습니까? – Naruto

+0

예. 사용하는 전체 버튼 안에 선형 레이아웃을 래핑하십시오. 버튼을 수평 또는 수직으로 정렬하는 유형은 언급하지 않았습니다. –

관련 문제