android RadioButton issue in android 4
Asked Answered
B

4

11

I have a simple application. The screen is build inside a RelativeLayout. I have more LinearLayout(s), one of them shows the 2 RadioButton(s), like this:

        <LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent"
            android:padding="3dp" android:gravity="center">
            <RadioGroup android:id="@+id/rgrDayToReport" 
                android:orientation="horizontal" 
                android:layout_width="wrap_content" android:layout_height="wrap_content">
                <RadioButton android:checked="true" android:id="@+id/rbtnToday"
                    android:layout_width="wrap_content" android:layout_height="wrap_content"

                    android:text="@string/radioTodayText"/>
                <RadioButton  android:id="@+id/rbtnYesterday"
                    android:layout_width="wrap_content" android:layout_height="wrap_content"

                    android:text="@string/radioYesterdayText"/>
            </RadioGroup>
        </LinearLayout>

This panel render correctly in any device (as I did tests) except Samsung Galaxy s3. On this device (only on this device) the screen looks like this:

enter image description here

How should I fix this?

Breathing answered 16/12, 2012 at 13:34 Comment(6)
Can you maybe show an image of how it should be (considering you said you've done tests on other devices)? Because I don't really understand what is wrong..Basaltware
@Basaltware well, its clear that the text is overlapping the RadioButtons' images.Romaromagna
On the other devices the text is on left of the circle. Normal RadioButton render.Breathing
Ah, stupid remark.. I think this is probably not something you can solve programmatically. But maybe you can contact Samsung for this, because I think this is probably just a bug in the Galaxy S3 if you say it works good on all other devicesBasaltware
Looks like it has to do with the customized themes vendors use to replace the default ones with.Also, you can try setting theme to device-default and see if that fixes this.Innominate
See possible duplicate: #7248422Anticline
F
15

I was experiencing the same problem. I have solved this by NOT setting paddingLeft on RadioButtons and CheckBoxes - leaving default value. paddingLeft was counted from the drawable on all phones and from left corner on Galaxy S3. Also setting background was causing the same bug on Galaxy S3. After leaving default values it's now usable everywhere.

Frisette answered 22/1, 2013 at 12:43 Comment(5)
As you can see in my code, there are no padding or background in my XML. And till the render is not correct.Breathing
I know, I'm just posting this because it can be related.Drumfire
Setting a custom state-list drawable as background for the radio buttons was causing the text to overlap on the check box for me. Interestingly this was reproducible on my Samsung tab2, Sony Exp Z but neither on Nexus 4 nor on emulators.Oilskin
I really hate Samsung for corrupting Android with their flaws... I've wasted so much time trying to solve this issue. BTW the bug is also present in the original Samsung Galaxy (samsung_sgh_t959v).Lovegrass
Samsung is the Internet Explorer of Android Devices.Koby
C
5

This might be too late, but i had the same problem and it was solved by specifying a android:drawableRight or android:drawableLeft, instead of android:button which is set by default

Contrarious answered 26/6, 2014 at 12:45 Comment(0)
A
0

Testing on a Rugby Pro and a GS5, I found that if you want to set the background color, you have to do it in the java, rather than in the XML. If you do it in XML, Samsung devices have an issue and cause the overlap.

Adjudicate answered 21/7, 2015 at 13:40 Comment(0)
K
-2

I solved this by setting the paddingLeft of the RadioButton to some value that made it look proper. I've only tested this on my Samsung device and not any other devices so I'm not sure what that will look like on your devices that "worked".

Knipe answered 29/12, 2012 at 20:12 Comment(2)
Thanks for answer, but if I do that then I'll have a normal look in S3 and a extra space in all the other devices. This is not a working solution, I thought to this by myself too.Breathing
I tested my proposed solution on a Verizon Galaxy S3, a Galaxy Tab, and a Nexus S and everything looks perfectly fine. Maybe this would work for your case as well.Knipe

© 2022 - 2024 — McMap. All rights reserved.