Reputation: 2467
in my simple app i use 2 radio button inside the radiogroup. on google devices (Nexus, Samsung nexus) everything display correctly, but on some other devices as Sony Experia, Samsung S III the label of radio button padding under the circle button. i use the image for radio button and use paddingLeft for get the gap between the label and radio button. this is my code:
<RadioGroup
android:id="@+id/radioGrpBitRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btnPlay"
style="@style/RadioGroup" >
<RadioButton
android:id="@+id/radio128"
style="@style/RadioButton128"
android:layout_height="wrap_content"
android:gravity="center|right" />
<RadioButton
android:id="@+id/radio32"
style="@style/RadioButton32"
android:gravity="center|right" />
</RadioGroup>
and the style
<style name="RadioGroup">
<item name="android:layout_marginTop">25dp</item>
<item name="android:layout_marginLeft">15dp</item>
</style>
<style name="RadioButton128" parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/radio</item>
<item name="android:text">@string/radio128String</item>
<item name="android:checked">true</item>
<item name="android:onClick">actionPlay128</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:paddingBottom">6dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#ededed</item>
</style>
<style name="RadioButton32" parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/radio</item>
<item name="android:text">@string/radio32String</item>
<item name="android:checked">false</item>
<item name="android:onClick">actionPlay32</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#ededed</item>
</style>
Upvotes: 0
Views: 1809
Reputation: 13887
I think this may be related to a similar issue that I had with checkboxes.
Prior to android version 17 the paddingLeft included the size of the checkbox itself whereas after android version 17 it is the padding between the checkbox and the text.
I therefore defined a dimension in the normal values/dimens.xml for the checkbox size + the padding I wanted and created a values-v17/dimens.xml which just included the padding.
E.g. values/dimens.xml
<dimen name="checkbox_size">42dp</dimen> <!-- 5dp plus 37dp of standard checkbox -->
values-v17/dimens.xml
<dimen name="checkbox_size">5dp</dimen>
And then updating the paddingLeft in your style to checkbox_size.
I don't know what the standard size of a radio button is or even if this is the same issue but it might just work.
Upvotes: 1