Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadioButton not drawing background correctly

Alright, I'm at my wits end with this one. I am using an open-source piece of code for segmented radio buttons (https://github.com/makeramen/android-segmentedradiobutton) and it's working great, except for the few devices where it won't draw the radio buttons correctly.

This is how it should look like:

enter image description here

And this is what it's looking like on the Xperia X10 and Acer Liquid E:

enter image description here

I have been Googling for an answer and still have no luck so I thought I would come here and see if anyone had any idea what could be causing it. I'm basically using the same code as the examples but here part of the layout for reference:

<com.makeramen.segmented.SegmentedRadioGroup android:id="@+id/jfl_calendar_tabselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/all_button">
    <RadioButton android:id="@id/all_button"
        android:minWidth="80dip"
        android:minHeight="50dip"
        android:text="@string/calendar_all"
        android:button="@null"
        android:textSize="13dip"
        android:gravity="center"
        android:textColor="@color/radio_colors" />  
    <RadioButton android:id="@+id/mine_button"
        android:minWidth="80dip"
        android:minHeight="50dip"
        android:text="@string/calendar_mine"
        android:button="@null"
        android:textSize="13dip"
        android:gravity="center"
        android:textColor="@color/radio_colors" 
        android:padding="3dip" />
    <RadioButton android:id="@+id/friends_button"
        android:minWidth="80dip"
        android:minHeight="50dip"
        android:text="@string/calendar_friends"
        android:button="@null"
        android:textSize="13dip"
        android:gravity="center"
        android:textColor="@color/radio_colors"
        android:padding="3dip" />
</com.makeramen.segmented.SegmentedRadioGroup>

Any help would be greatly appreciated!

like image 359
SpencerElliott Avatar asked Jun 02 '11 19:06

SpencerElliott


1 Answers

I had the same issue with a Sony Ericsson device... the workaround I used was to set the background in the xml:

<RadioButton android:id="@id/button_one"
    android:minWidth="40dip"
    android:minHeight="33dip"
    android:text="One"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:button="@null"
    android:gravity="center"
    android:background="@drawable/segment_radio_left" <-- setting the BG here
    android:textColor="@color/radio_colors" />

After doing this the background rendered correctly when first appearing and when changing between buttons.

So if your radiobuttons are defined in a static way in the xml, setting the background drawable of the left, middle, and right buttons in the xml should work.

like image 166
Stephen Asherson Avatar answered Oct 14 '22 19:10

Stephen Asherson