popupMenuStyle doesn't work when I change parent=“@style/Theme.AppCompat.Light.DarkActionBar”>

瘦欲@ 提交于 2020-01-23 07:14:27

问题


When I change my theme styles

<style name="Theme.mystyle" parent="@style/Theme.AppCompat.Light">

to

<style name="Theme.mystyle" parent="@style/Theme.AppCompat.Light.DarkActionBar">

Not working at all.

<style name="PopupMenu.mystyle" parent="@style/Widget.AppCompat.Light.PopupMenu">
    <item name="android:textStyle">bold</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel</item>
</style>

回答1:


Check this generator to get working styles: http://jgilfelt.github.com/android-actionbarstylegenerator/

Basically when switching to DarkActionBar you need to update your styles to follow:

<style name="Theme.Example" parent="@style/Theme.AppCompat.Light.DarkActionBar">
   <item name="android:popupMenuStyle">@style/PopupMenu.Example</item>
   <!-- Light.DarkActionBar specific -->
   <item name="android:actionBarWidgetTheme">@style/Theme.Example.Widget</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="@style/Theme.AppCompat">    
    <item name="android:popupMenuStyle">@style/PopupMenu.Example</item>    
    <item name="android:dropDownListViewStyle">@style/DropDownListView.Example</item>    
</style>


来源:https://stackoverflow.com/questions/21381210/popupmenustyle-doesnt-work-when-i-change-parent-style-theme-appcompat-light-d

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