I am working on an app that uses a theme that extends @style/Theme.AppCompat.Light.DarkActionBar
.
On one of my activities, there is an Action Bar icon that shows three options with radiobuttons (here's an extract from the menu XML file):
<item
android:icon="@drawable/ic_action_filter_white"
android:showAsAction="always"
android:title=""
preparatest:showAsAction="always">
<menu>
<group android:checkableBehavior="single" >
<item
android:id="@+id/menu_filter_all"
android:title="@string/history_list_filter_all"
android:checked="true"/>
<item
android:id="@+id/menu_filter_pending"
android:title="@string/history_list_filter_pending"/>
<item
android:id="@+id/menu_filter_finished"
android:title="@string/history_list_filter_finished"/>
</group>
</menu>
</item>
I want to give these radiobuttons a custom style, but I don't know where to do it. On my styles.xml file I have defined the custom style as
<style name="RadioButtonPTGreenTheme" parent="android:Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/ptgreentheme_btn_radio_holo_light</item>
</style>
and tried using all these four options, but to no avail:
<item name="android:radioButtonStyle">@style/RadioButtonPTGreenTheme</item>
<item name="android:listChoiceIndicatorSingle">@style/RadioButtonPTGreenTheme</item>
<item name="android:radioButtonStyle">@drawable/ptgreentheme_btn_radio_holo_light</item>
<item name="android:listChoiceIndicatorSingle">@drawable/ptgreentheme_btn_radio_holo_light</item>
Does anyone know how to do this? Thanks!
See this blog post for a way to do it.
Long story short,
android:actionBarWidgetTheme
is used to style elements that depend on the Action Bar, so theandroid:radioButtonStyle
should be put inside a style for actionBarWidgetTheme: