RadioButton does not paint the background correctly

Well, I agree with that. I use an open source piece of code for segmented radio buttons ( https://github.com/makeramen/android-segmentedradiobutton ) and it works fine except for a few devices where it will not draw radio buttons correctly.

Here's how it should look:

enter image description here

And this is what it looks like on the Xperia X10 and Acer Liquid E:

enter image description here

I was googling for an answer and still no luck, so I thought I would come here and see if anyone knew what might cause him. I mostly use the same code as the examples, but here is 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!

+7
source share
2 answers

I had the same problem with a Sony Ericsson device ... the workaround I used was to set the background in 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 that, the background is displayed correctly when it first appears and when changing between buttons.

So, if your radio objects are set statically in xml, setting the background image of the left, middle and right buttons in xml should work.

+6
source

I have never used segmented switch code, so I am not familiar with it, but do you have the PNG source resources in the corresponding res / drawable / * dpi folders for these phones? I believe the X10 Mini is an LDPI device that can explain the lack of background ...

0
source

All Articles