Styling buttons on ActionBarCompat dropdown menu

I am working on an app that uses theme extending @style/Theme.AppCompat.Light.DarkActionBar

.

One of my actions has an action bar icon that shows three options via radio objects (here's an excerpt from the XML menu 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 these radio objects to be the normal style, but I don't know where to do this. In 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 to use all these four parameters 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? Thank!

+1


source to share


1 answer


See this blog post to do this.

In short, it is android:actionBarWidgetTheme

used for styles of elements that depend on the action bar, so android:radioButtonStyle

should be placed inside the style for actionBarWidgetTheme:



<style name="MyTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarWidgetTheme">@style/MyActionBarWidgetTheme</item>
</style>

<style name="MyActionBarWidgetTheme" parent="@android:style/Theme.Holo">
    <item name="android:radioButtonStyle">@style/MyRadioButtonStyle</item>
</style>

      

+1


source







All Articles