16

I've got an custom theme with a parent @android:style/Theme.Holo.Light.DarkActionBar I want to change the dropdown menu into the white version (see image)

I have looked up some examples, but they didn't work out for me, is it possible to just override the dropdown menu from the DarkActionBar with the light version?

(I dont use the sherlock actionbar)

enter image description here

Carlo Matulessy
  • 975
  • 1
  • 13
  • 27
  • I tend to just use this http://jgilfelt.github.io/android-actionbarstylegenerator/ – Broak Jan 14 '14 at 12:11
  • Check out this post, [http://stackoverflow.com/questions/16878662/how-to-set-the-background-of-android-popupmenu-to-white](http://stackoverflow.com/questions/16878662/how-to-set-the-background-of-android-popupmenu-to-white) I think it is the same issue. – JoePhillips Jan 14 '14 at 12:15

2 Answers2

20

This worked for me. Hope it help:

<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>
Thuy Trinh
  • 2,914
  • 1
  • 22
  • 35
  • 7
    Any chance this just doesn't work in Light.DarkActionbar? I keep getting the dark dropdown. - Doesn't seem to work with default dark either. maybe because I'm using AppCompat – Mathijs Segers Apr 08 '14 at 07:37
  • 1
    As expected, same thing for Material themes (replace `Holo` with `Material`, of course). – davidcesarino Oct 04 '14 at 18:32
1

use the same context of actionBar to create the PopupMenu

actionBar.getThemedContext()

So,

ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar();
PopupMenu popMenu = new PopupMenu(actionBar.getThemedContext(), anyView);

Guihgo
  • 632
  • 10
  • 13