adrian
adrian

Reputation: 2376

Styling Action Bar Overflow Menu background color

So I'm trying to style the action bar overflow menu but am having no luck at all. For some reason, the style I'm trying to apply (white background) is like getting overridden completely somewhere. Any ideas?

<style name="AppTheme" parent="android:Theme.DeviceDefault.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:editTextStyle">@style/App.EditText</item>
        <item name="android:textColor">@color/night</item>
        <item name="android:listPopupWindowStyle">@style/ListPopupWindow</item>
    </style>


 <style name="PopupMenu" parent="android:Widget.ListPopupWindow">
        <item name="android:popupBackground">@color/white</item>
    </style>

enter image description here

Upvotes: 0

Views: 1357

Answers (3)

Rushabh Patel
Rushabh Patel

Reputation: 3080

you can use the below lines to change the background of the OverFlow Menu..

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

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@android:color/black</item>
</style>

Hope it will help you..

Upvotes: 0

nithin
nithin

Reputation: 2467

Try this

<style name="YOUR_DARK_AB_THEME">
    <item name="android:actionBarWidgetTheme">@style/YourActionBarWidget</item>
</style>

<!-- This helps the PopupMenu stick with Light theme while the ActionBar is in Dark theme -->
<style name="YourActionBarWidget"
    parent="android:Theme.Holo.Light">
    <item name="android:popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item>
    <item name="android:dropDownListViewStyle">@android:style/Widget.Holo.Light.ListView.DropDown</item>
</style>

Upvotes: 0

adrian
adrian

Reputation: 2376

Found the solution,

Hope this will help others.

http://daniel-codes.blogspot.com/2012/11/the-unknown-style-actionbarwidgettheme.html

Basically you need to generate a new theme (style) for android:actionBarWidgetTheme which will be used for inflation to properly style the menu items as needed.

    <item name="android:actionBarWidgetTheme">@style/ActionBarWidgetTheme</item>


<style name="ActionBarWidgetTheme" parent="android:Theme.DeviceDefault.Light.DarkActionBar">
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView</item>
    </style>

Upvotes: 1

Related Questions