Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dark actionbar with white dropdown menu from Holo Light

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

like image 427
Carlo Matulessy Avatar asked Jan 14 '14 12:01

Carlo Matulessy


2 Answers

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>
like image 71
Thuy Trinh Avatar answered Sep 23 '22 06:09

Thuy Trinh


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);

like image 29
Guihgo Avatar answered Sep 26 '22 06:09

Guihgo