2012-06-12 3 views
0

이것은 스크린 샷입니다. 이 버튼을 모든 장치에 맞게 화면에 표시하고 싶습니다.모든 위젯을 화면에 맞춤

Button6 뒤에 공백을 제거하고 모든 버튼을 화면에 맞추고 싶습니다.

Image

+1

그런 다음 xml 파일의 버튼에서 layout_weight를 속성으로 사용하십시오. – Carnal

+0

relativelayout을 사용할 때 어떻게 가능합니까? –

+0

직선형이므로 LinearLayout을 사용합니다. 그러나 RelativeLayout을 사용해야하는 경우에는 단추를 LinearLayout에 추가 한 다음 layout_weight 특성을 추가 할 수 있습니다. – Carnal

답변

3
<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 
</LinearLayout> 
+1

layout_height에서 fill_parent 여야합니다. – Carnal

+1

둘 다 동일한 UI를 제공합니다. 정보를 보내 주셔서 감사합니다. – VenomVendor

2

사용 :

고해상도/값 - LDPI/dimens.xml

고해상도/값 - MDPI/dimens.xml

고해상도/값-hdpi에/dimens.xml

버튼 높이 설정

<!-- in values-ldpi/dimens.xml --> 
<dimen name="height">25dip</dimen> 

<!-- in values-mdpi/dimens.xml --> 
<dimen name="height">30dip</dimen> 

<!-- in values-hdpi/dimens.xml --> 
<dimen name="height">40dip</dimen> 
관련 문제