popupMenuStyle doesn't work when I change pare

2019-04-30 05:54发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-04-30 06:44

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>
查看更多
登录 后发表回答