Light.DarkActionBar菜单项的文字颜色不变? [英] Light.DarkActionBar menu item text colour unchangeable?

查看:466
本文介绍了Light.DarkActionBar菜单项的文字颜色不变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序我一直在开发利用ActionBarSherlock,并主旋律从Theme.Sherlock.Light.DarkActionBar继承。设计要求溢出菜单的弹出窗口有一个深色背景和白色文字。这工作正常的设备没有物理菜单按钮,按照预期的文本显示为白色。但是,如果设备有实体的菜单按钮,在弹出的菜单中显示的文本保持黑色。

The application I've been developing uses ActionBarSherlock, and the main theme inherits from Theme.Sherlock.Light.DarkActionBar. The design requires that the overflow menu popups have a dark coloured background and white text. This works fine for devices without a physical menu button, and the text appears white as intended. However, if the device DOES have a physical menu button, the text shown in the menu displayed remains black.

我的主题包含了

<item name="android:panelBackground">@drawable/menu_hardkey_panel</item>

...其中@可绘制/ menu_hardkey_panel是深色9patch。

...Where @drawable/menu_hardkey_panel is a dark coloured 9patch.

在弹出菜单中生成的外观...

The resulting appearance of the menu popup is...

我无法确定为什么发生这种情况,或如何手动更改文本的颜色。在我的主题,我已经试过所有的以下...

I'm unable to determine why this is happening, or how to manually change the colour of the text. In my main theme, I've tried all of the following...

<item name="android:actionMenuTextColor">@android:color/white</item>
<item name="android:textAppearanceLargePopupMenu">@style/MyMenuTextAppearance.Large</item>
<item name="android:textAppearanceSmallPopupMenu">@style/MyMenuTextAppearance.Small</item>

我甚至试过

<item name="android:actionBarWidgetTheme">@style/Theme.MyApp.Dark</item>

...其中Theme.MyApp.Dark是...

...Where Theme.MyApp.Dark is...

<style name="Theme.MyApp.Dark" parent="@style/Theme.Sherlock">
    <item name="android:dropDownListViewStyle">@style/DropDownListView</item>
    <item name="dropDownListViewStyle">@style/DropDownListView</item>
</style>

无已让我的文字更改为白色。如果让我从Theme.Sherlock我的基本主题继承,问题解决和文字是白色的,但不幸的是,这不是一个选项。

None have let me change the text to white. If I make my base theme inherit from Theme.Sherlock, the problem is solved and the text is white, but unfortunately that's not an option.

推荐答案

在我的研究,我还没有找到一种方法来改变文字颜色,但你至少可以处理的硬键菜单摆好。

In my research I haven't found a way to change the text color, but you can at least handle hardkey menus gracefully.

该链接为我提供了一个差强人意的解决问题的办法: https://github.com/jgilfelt/android-actionbarstylegenerator/issues/30

This link provided me with a passable solution to the problem: https://github.com/jgilfelt/android-actionbarstylegenerator/issues/30

注释了机器人:panelBackground项目从我的生成主题允许的文本,至少是对硬键菜单中可见,即使它并不完全匹配的主题

Commenting out the "android:panelBackground" item from my generated theme allowed the text to at least be visible on hardkey menus, even if it doesn't perfectly match the theme.

您也可以尝试更换menu_hardkey_panel_的任何的.9.png绘制的东西,会为你的主题和黑色文本。

You could also try replacing the "menu_hardkey_panel_whatever.9.png" drawable with something that will work for your theme and the black text.

这篇关于Light.DarkActionBar菜单项的文字颜色不变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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