Question

I am able to style overflow menu which pops up from action bar but I am not able to style overflow menu which pops up from hardware menu button.

I am interested in styling states of selector for the item in menu.

any ideas are welcome?

Was it helpful?

Solution

For customize the popup menu which is displayed with the hardware menu button, you need to have this item in your app theme:

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:itemBackground">@drawable/ab_item_selector</item>  
</style> 

You can change @style/Theme.AppCompat.Light according to your needs (as Holo or something else). Then, the drawable named ab_item_selector might be this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- selected state -->
    <item 
        android:drawable="@drawable/item_selected" 
        android:state_selected="true"></item>
    <!-- pressed state -->
    <item 
        android:drawable="@drawable/item_pressed" 
        android:state_pressed="true"></item>
    <!-- normal state -->
    <item 
        android:drawable="@drawable/item_disabled"></item>
</selector> 

Hope this helps.


UPDATE

For dividers, I'm not sure but it might be:

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:dropDownListViewStyle">@style/CustomDropDown</item>
    <item name="dropDownListViewStyle">@style/CustomDropDown</item>
</style>

<style name="CustomDropDown" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
    <item name="android:dividerHeight">1dip</item>
    <item name="android:divider">@drawable/dropdown_divider</item>
</style>  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top