本文介绍了如何在带有 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:

我正在使用这些样式:

<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>

推荐答案

我已经调查过这个问题.并且似乎无法使用硬件菜单键更改 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.

但是,您可以将Android >= 4.0 硬件关键设备底部选项菜单的背景与非硬件关键下拉菜单的背景分开设置.

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.

您已经拥有非硬件键下拉菜单的样式.非硬件键下拉菜单由 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 key 底部选项菜单的背景是用主题中的android:panelBackground项定义的:

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 硬件关键设备上更改底部选项菜单的文本颜色似乎有问题,我建议将此部分保留为其默认样式.

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> 4.0 和硬件按钮的设备上设置操作溢出菜单中的文本样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:51