Question

How can I set theme Holo.Dark only for menu (form menu button)?

I tried this:

<style name="menu" parent="@android:style/Theme.Holo.Light"></style>

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/menu">
    <item 
        android:id="@+id/settings"
        android:title="@string/settings"
        style="@style/menu"/>
</menu>

But this doesn't work. How should I do that?

Was it helpful?

Solution

Try to set it in your style.xml in general, not with the style attribute in your xml layout:

<style name="MyTheme" parent="@style/Theme.Light">
    <item name="android:popupMenuStyle">@style/PopupMenu</item>
    <item name="android:dropDownListViewStyle">@style/DropDownList</item>  
</style>

<!-- You can change the parent style as "@style/Widget.AppCompat.ListPopupWindow" -->
<style name="PopupMenu" parent="@style/Widget.Holo.ListPopupWindow">
    <item name="android:popupBackground">@android:color/background_dark</item>
</style>

<style name="DropDownList" parent="@style/Widget.Holo.ListView.DropDown">
    <!-- background of the list menu -->
    <item name="background">@android:color/background_dark</item>
    <item name="android:background">@android:color/background_dark</item>
    <item name="android:popupBackground">@android:color/background_dark</item>
    <!-- dividers -->
    <item name="android:divider">@android:color/grey</item>
    <item name="divider">@android:color/grey</item>
    <item name="android:dividerHeight">1dip</item>
    <!-- item selected -->
    <item name="android:dropDownSelector">@android:color/holo_blue_dark</item>
    <item name="android:listSelector">@android:color/holo_blue_dark</item>
</style>

Read this article for more info, and this Android Documentation Color to get the right color for the background, dividers, text color, etc.
You also can do this dynamically and customize this menu: Menus My Way.
Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top