android RadioButton issue in android 4

南笙酒味 提交于 2020-01-01 08:28:26

问题


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:

How should I fix this?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/13901789/android-radiobutton-issue-in-android-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!