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?
Checking Current State Of Radio Button: You can check the current state of a radio button programmatically by using isChecked() method. This method returns a Boolean value either true or false. if it is checked then returns true otherwise returns false.
To get the selected radio button, we have used radioGroup. getCheckedRadioButtonId() method, which returns the id of the selected radio button. Then to get the text of the selected radio button, we have used getText() method on that selected radio button.
Radio buttons allow the user to select one option from a set. You should use radio buttons for optional sets that are mutually exclusive if you think that the user needs to see all available options side-by-side. If it's not necessary to show all options side-by-side, use a spinner instead.
If you are only using one radio box for checking on and off, maybe you should use checkbox or toggle button instead. Scroll down and see checkbox and toggle button. When using radios you usually have more than one and choose between them.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With