I'm making my app ready for Android 5.0, I'm using the latest compatibility library, here is what my style looks like.
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/theme_accent</item>
<item name="colorAccent">@color/theme_accent_secondary</item>
</style>
<style name="AppThemeDark" parent="Theme.AppCompat">
<item name="colorPrimary">@color/theme_accent</item>
<item name="colorAccent">@color/theme_accent_secondary</item>
</style>
</resources>
(The ActionBar color is being set programmatically.)
Now, I want the overflow/popup menu to have the dark background like it had in the holo implementation, but I can't get it to work, here is what it looks like:
I have tried setting the popupMenuStyle
but it didn't work.
How can I make the popup menu darker?
Add the property popupTheme to your toolbar:
Or define a new style for your toolbar:
Not a full answer but what I found so far:
In past versions you needed to specify a drawable (Check https://github.com/StylingAndroid/StylingActionBar code and tutorials)
Apparently, now that is a color. To modify it you need to do specify the following theme:
This works correctly if the theme applied to the app is just this. If I add
android:actionBarPopupTheme
to my existing theme, it doesn't work. I am trying to figure out why.Solved my problem by using this style:
I had to use Widget.AppCompat.Toolbar as the parent actionBarStyle
This question has already been answered for styling via XML, but I'm adding an explanation here of how to work out the solution to this and similar styling questions yourself.
First, this is the solution when using AppCompat. To your App's style.xml add actionBarPopupTheme to your theme:
Here's the steps I took to arrive at this solution (it takes a bit of detective work as the Android documentation is poor):
Within this style I saw this line:
< item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light< /item>
This looked like a possible place to change the theme of the popup. I searched for "actionBarPopupTheme" in the poor Android developers documentation and found "Reference to a theme that should be used to inflate popups shown by widgets in the action bar". So this was worth playing with.
I copied the appcompat line containing "actionBarPopupTheme" to my style.xml then in this line replaced the item's theme reference (the bit in bold above) with Theme.MyTheme.ActionBarPopupTheme.
Stop using the
ActionBar
. If you want aToolBar
to be set up like anActionBar
, follow this guide on the android-developers blog.It actually mentions your use case at Dark Action Bar and provides this code: