【问题标题】:How to change color to text of ActionBar's menu items?如何将颜色更改为 ActionBar 菜单项的文本?
【发布时间】:2014-04-30 15:28:53
【问题描述】:

我想更改操作栏中菜单项文本的颜色。我试图改变主题,但没有任何效果。我正在使用 API 19:

这是我的res\values\styles.xml

<resources>
    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

    <style name="LoginFormContainer">
        <item name="android:padding">28dp</item>
    </style>
</resources>

项目还在res\values-v11\res\values-v14\中生成styles.xml

我不知道我是否必须更改主题或只是设置一个属性或其他东西,任何帮助我都会非常感激。谢谢!

【问题讨论】:

标签: android menuitem android-theme android-menu


【解决方案1】:

我终于找到了解决问题的方法。这是我的最终代码:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!-- API 14 theme customizations can go here. -->
        <item name="android:textAppearanceLargePopupMenu" >@style/m_textAppearanceLargePopupMenu</item>
        <item name="android:textAppearanceSmallPopupMenu" >@style/m_textAppearanceSmallPopupMenu</item>
    </style>

    <style name="m_textAppearanceLargePopupMenu" parent="@android:style/TextAppearance.Holo.Widget.PopupMenu.Large">
        <item name="android:textColor">#009ad2</item>
    </style>
    <style name="m_textAppearanceSmallPopupMenu" parent="@android:style/TextAppearance.Holo.Widget.PopupMenu.Small">
        <item name="android:textColor">#009ad2</item>
    </style>

</resources>

这是我的res\values-v14\ 文件代码。

我很困惑,我真正想要的是将文本颜色更改为 PopupMenu,它对我有用。

感谢朋友的帮助!!

【讨论】:

    【解决方案2】:

    自定义文本颜色部分中查看Documentation。它说明了您必须针对不同的 android API 级别执行此操作的方式。

    【讨论】:

    • Saludos desde Sonsonate.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多