Dark actionbar with white dropdown menu from Holo Light

非 Y 不嫁゛ 提交于 2019-11-29 02:27:11

问题


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)


回答1:


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>



回答2:


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



来源:https://stackoverflow.com/questions/21113079/dark-actionbar-with-white-dropdown-menu-from-holo-light

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!