CAB溢出菜单自定义样式 [英] CAB overflow menu custom style

查看:257
本文介绍了CAB溢出菜单自定义样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我显示上下文操作栏因为我没有足够的空间供所有的动作,其中一些在溢出菜单按钮进行访问。现在我想的样式溢出菜单,改变它的背景。我的主题从Theme.AppCompat继承,我有这些样式定义的:

In my application I am showing a contextual action bar and because I don't have room for all the actions, some of them are accessed under the overflow menu button. Now I want to style the overflow menu and change its background. My theme inherits from Theme.AppCompat, and I have these styles defined:

<item name="android:popupMenuStyle">@style/PopupMenu</item>
<item name="android:listPopupWindowStyle">@style/PopupMenu</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView</item>

<style name="PopupMenu" parent="Widget.AppCompat.PopupMenu">
    <!--<item name="android:popupBackground">@color/dark_color</item>-->
    <item name="android:textColor">?android:textColorPrimary</item>
    <item name="android:dropDownSelector">?popupItemBackground</item>
</style>

<style name="DropDownListView" parent="Widget.AppCompat.ListView.DropDown">
    <item name="android:listSelector">?popupItemBackground</item>
    <item name="android:divider">@null</item>
    <item name="android:dividerHeight">0dp</item>
</style>

在我的应用程序中的其它菜单(溢出菜单的操作栏等)的风格,但在上下文操作栏的溢出菜单中是没有的。我该怎么办?

The other menus in my application (overflow menus in action bar and other) are styled, but the contextual action bar's overflow menu is not. What should I do?

推荐答案

我终于有了一个解决方案。看来你需要将它添加到你的主题:

I finally have a solution. It seems that you need to add this to your theme:

<item name="actionBarPopupTheme">@style/ThemeOverlay.My</item>

其中:

<style name="ThemeOverlay.My" parent="ThemeOverlay.AppCompat">
    <item name="android:colorBackground">@color/my_theme_background</item>
</style>

该colorBackground属性可以把你喜欢这样,你有上下文的动作按钮的溢出菜单风格的任何​​颜色值。

The colorBackground attribute can take any color value that you like and with this you have the contextual action button's overflow menu styled.

这篇关于CAB溢出菜单自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆