如何使用Android> 4.0和硬件按钮在设备上的动作溢出菜单中设置样式文本? [英] How to style text in action overflow menu on device with Android>4.0 and hardware button?

查看:188
本文介绍了如何使用Android> 4.0和硬件按钮在设备上的动作溢出菜单中设置样式文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要自定义背景&文字颜色为我的溢出菜单。它没有硬件菜单按钮的设备工作正常,但我无法使用硬件菜单按钮来设计样式。查看截图:

I would like custom background & text color for my overflow menu. It works fine with devices without hardware menu button, but I'm not able to style devices with hardware menu button. See the screenshots:


m使用这些样式:

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> 
    <item name="android:actionMenuTextColor">@android:color/white</item>
</style>
<style name="settleup_PopupMenu" parent="@style/Widget.Sherlock.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_settleup</item>
</style>


推荐答案

我已经研究了这个问题。而对于具有HW菜单键的Android> = 4.0设备的选项菜单,似乎没有办法更改 textColor 。甚至更改初级,二级或三级颜色影响文本颜色。

现在我想到的唯一解决方案是一些非常讨厌使用java反射API。

I've looked into the problem. And there seems to be no way in changing textColor for the options menu for Android >= 4.0 devices with HW menu key. Not even changing primary, secondary or tertiary colors affected the text color.
The only "solution" that comes to my mind now is some pretty nasty use of java reflection API.

但是,您可以从非HW键下拉菜单的背景中分别设置Android> = 4.0 HW键设备底部选项菜单的背景。

However, you can set the background of the bottom options menu of Android >= 4.0 HW key devices separately from the background of the non-HW key dropdown menu.

您已经拥有非HW键下拉菜单的样式。非HW键下拉菜单由 android:popupMenuStyle (和 popupMenuStyle )定义:

You already has the styling for non-HW key dropdown menu. The non-HW key dropdown menu is defined by android:popupMenuStyle (and popupMenuStyle):

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> 
</style>

但Android> = 4.0 HW键底部选项菜单的背景是用在主题中的项目:

But the background of the Android >= 4.0 HW key bottom options menu is defined with android:panelBackground item in the theme:

<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="android:panelBackground">@drawable/mybackground</item>
</style>

由于在Android> = 4.0上更改底层选项菜单的文本颜色似乎是一个问题HW键设备,我建议离开这部分到它的默认样式。

Since it seems to be a problem to change the text color for bottom options menu on Android >= 4.0 HW key devices, I would suggest to leave this part to its default styling.

这篇关于如何使用Android&gt; 4.0和硬件按钮在设备上的动作溢出菜单中设置样式文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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