2012-01-06 55 views
-1

的我使用的是相对布局内的单选按钮,这里是我的代码我的单选按钮外出屏幕

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="fill_parent" > 

<FrameLayout android:id="@+id/frameLayout" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_alignParentTop="true" 
    android:layout_above="@+id/radioButtonGroupLayout"> 
<!-- Put fragments dynamically --> 

</FrameLayout> 


<RadioGroup android:id ="@+id/radioButtonGroupLayout" android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" android:layout_alignParentBottom="true"> 

    <RadioButton android:id="@+id/RadioButton1" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_1_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton2" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_2_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton3" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_3_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton4" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_4_selector" android:background="@drawable/ip4_menu_background_short72"/> 
    <RadioButton android:id="@+id/RadioButton5" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:button="@drawable/ip4_menu_but_5_selector" android:background="@drawable/ip4_menu_background_short72"/> 
</RadioGroup> 
</RelativeLayout> 

最后一个单选按钮都没有在屏幕上。我只能看到前4个单选按钮,而且最后一个按钮很多。我的代码有什么问题?

+0

你能给我们看一个截图吗?这是可能的,因为您正在使用wrap_content作为单选按钮,它们显示的大小与您用于按钮和背景的可绘制对象相同。我会建议改变这些高度和宽度到一个固定的DP,这样它会更好地扩大到更大/更小的屏幕。 – 2012-01-06 10:21:41

+0

谢谢迈克尔,我改变了图像大小,并且还向所有单选按钮添加了layout_weight =“1”来分配剩余的空间..并且它的工作...感谢您的所有帮助 – Nik 2012-01-06 10:29:28

+1

尝试将所有内容嵌套在滚动视图中。 – Ghost 2012-01-06 10:29:41

回答

0

这是可能的,因为您正在使用wrap_content作为单选按钮,它们显示的尺寸与您用于按钮和背景的可绘制尺寸一样大。我会建议改变这些高度和宽度到一个固定的DP,这样它会更好地扩大到更大/更小的屏幕。

添加了评论作为答复,让这个问题被关闭。

0

使用android:layout_weight =“1”与每个单选按钮。它会显示任何大小的屏幕上的所有5个按钮。

<RadioButton 
     android:id="@+id/RadioButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" /> 

请对所有单选按钮做同样的操作。