-1

I am using Radio Buttons inside a relative layout, here is my code

<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>

The last radio button are not on the screen. I can see only first 4 radio buttons and and lot the last one. What's wrong in my code?

halfer
  • 19,824
  • 17
  • 99
  • 186
Nik
  • 2,913
  • 7
  • 40
  • 66
  • Can you show us a screen shot? It's possible, since you are using wrap_content for the radio buttons that they are displaying as large as the drawables you are using for the button and background. I would recommend changing these heights and widths to a fixed dp, this way it will scale better to larger/smaller screens. – Michael Allen Jan 06 '12 at 10:21
  • Thank you Michael, I changed the image sizes and also added layout_weight = "1" to all radio buttons to allocate the space is remaining.. and its working... thank you for all your help – Nik Jan 06 '12 at 10:29
  • 1
    Try nesting everything inside a Scroll View. – Ghost Jan 06 '12 at 10:29

2 Answers2

0

use android:layout_weight="1" with each radio button. It will show you all 5 buttons on screen of having any size.

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

please do the same with all radio buttons.

akshay
  • 5,811
  • 5
  • 39
  • 58
0

It's possible, since you are using wrap_content for the radio buttons that they are displaying as large as the drawables you are using for the button and background. I would recommend changing these heights and widths to a fixed dp, this way it will scale better to larger/smaller screens.

Added this comment as an answer so the question can be closed.

Michael Allen
  • 5,712
  • 3
  • 38
  • 63