如何风格动作溢出菜单文字设备与Android> 4.0和硬件按钮? [英] How to style text in action overflow menu on device with Android>4.0 and hardware button?

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

问题描述

我想自定义背景和放大器;文本颜色为我的溢出菜单。它工作正常,无硬件菜单按钮的设备,但我不能风格的硬件菜单按钮的设备。见截图:

我使用这些样式:

 <样式名称=Theme.settleup父=@风格/ Theme.Sherlock.Light.DarkActionBar>
    <项目名称=机器人:popupMenuStyle> @风格/ settleup_PopupMenu< /项目>
    <项目名称=机器人:actionMenuTextColor> @android:彩色/白< /项目>
< /风格>
<样式名称=settleup_PopupMenu父=@风格/ Widget.Sherlock.ListPopupWindow>
    <项目名称=机器人:popupBackground> @可绘制/ menu_dropdown_panel_settleup< /项目>
< /风格>
 

解决方案

我已经研究过这个问题。而且似乎有没有办法改变文字颜色的为Android> = 4.0的设备与硬件菜单键选项菜单。甚至没有改变一级,二级或三级的颜色影响了文本颜色。
唯一的解决方案,在我脑海现在一些pretty的讨厌使用Java反射API。

不过,您可以分别从非硬件键下拉菜单的背景设定的Andr​​oid> = 4.0 HW关键设备底部的选项菜单的背景。

您已经拥有了造型的非硬件键下拉菜单。非硬件键下拉菜单由定义的android:popupMenuStyle (和 popupMenuStyle ):

<样式名称=Theme.settleup父=@风格/ Theme.Sherlock.Light.DarkActionBar&GT ;     <项目名称=机器人:popupMenuStyle> @风格/ settleup_PopupMenu< /项目> < /风格>

但Android的> = 4.0 HW键下方的选项菜单的背景定义的安卓:在主题panelBackground 项目:

<样式名称=Theme.settleup父=@风格/ Theme.Sherlock.Light.DarkActionBar&GT ;     <项目名称=机器人:panelBackground> @可绘制/ mybackground< /项目> < /风格>

因为它似乎是一个问题,改变文字颜色底部选项在Android> = 4.0 HW关键设备菜单,我会建议离开这个部分它的默认样式。

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:

I'm using these styles:

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

解决方案

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.

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.

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>

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>

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天全站免登陆