皮肤选项菜单Android

smo*_*ter 10 android android-layout android-menu

我正试图在android上设置选项菜单.我使用自定义主题更改了背景颜色,但由于某种原因我无法更改文本颜色.

我的主题

<style name="default" parent="@android:style/Theme.NoTitleBar">

    <!--  Menu panel colors -->
    <item name="android:panelBackground">@color/optionsMenuBackgroundColor</item>
    <item name="android:panelFullBackground">@color/optionsMenuBackgroundColor</item>

    <!--  Menu item colors -->
    <item name="android:itemTextAppearance">@style/OptionsMenuFont</item>

 </style>
Run Code Online (Sandbox Code Playgroud)

我的样式为选项菜单字体

<style name="OptionsMenuFont" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
    <item name="android:textColor">@drawable/menu_item_font</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我可以选择按钮颜色选择器menu_item_font.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <!--  Put other state colors up top -->


    <item android:color="@color/optionsMenuTextColor" />

</selector>
Run Code Online (Sandbox Code Playgroud)

那颜色只是一个十六进制颜色#c4c4c4

我在这里错过了什么?

Hal*_*alR 0

这个问题已经以不同的方式被问过很多次了。使用 XML 布局,您可以更改背景颜色,但不能更改文本颜色:

http://code.google.com/p/android/issues/detail?id=4441

但是,您可以编写一个自定义类来完成菜单换肤:

http://www.techjini.com/blog/customizing-background-and-text-color-in-options-menu-android/