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:
And this is what it's looking like on the Xperia X10 and Acer Liquid E:
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=开发者_如何学Go"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!
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.
I've never used the segmented radio button code so I'm not intimately familiar with it, but do you have the background PNG resources in the appropriate res/drawable/*dpi folders for those phones? I believe the X10 Mini is an LDPI device, which might account for the background going missing...
精彩评论