如何在材质设计中更改操作栏的菜单项文本颜色 [英] how to change actionbar's menu item text color in material design

查看:112
本文介绍了如何在材质设计中更改操作栏的菜单项文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使在较旧的设备上,我也试图更新我的记事本应用程序以使用Material Design.

I'm trying to update my notepad app to use Material Design, even on older devices.

到目前为止我做了什么:

What i did so far:

  1. 将库appcompat_v7添加到我的项目中,以支持旧设备上的Material Design
  2. 在AndroidManifest中修改主题,将android:theme="@style/Theme.NoteItTheme"添加到<application ... ></application>属性
  3. 在/res/values/themes.xml中创建主题:

  1. add library appcompat_v7 to my project, to support Material Design on older devices
  2. modify theme in AndroidManifest, adding android:theme="@style/Theme.NoteItTheme" to <application ... ></application> attributes
  3. creating the theme in /res/values/themes.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
   <style name="Theme.NoteItTheme" parent="Theme.AppCompat.Light">
    <!-- Here we setting appcompat’s actionBarStyle -->
    <!-- <item name="actionBarStyle">@style/MyActionBarStyle</item> --> 

    <!-- ...and here we setting appcompat’s color theming attrs -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="android:textColorPrimary">@color/text</item>
    <item name="colorAccent">@color/ui</item>

    <!-- The rest of your attributes -->
</style>

问题:

您可以在这里更好地看到它:

As you can better see here:

当我展开操作栏菜单时,文本颜色和背景颜色非常相似. 我以前没有这个问题,我该如何仅更改项目文本的颜色?

when i expand the actionbar's menu, text color and background color are very similar. I hadn't this problem before, how do i change just the items text color?

推荐答案

<item name="android:textColorPrimary">yourColor</item>

以上代码更改了API> = v21的菜单操作项的文本颜色.

Above code changes the text color of the menu action items for API >= v21.

<item name="actionMenuTextColor">@android:color/holo_green_light</item>

上面是API的代码< v21

Above is the code for API < v21

一些教程:

更改工具栏文字颜色和溢出图标颜色

Appcompat v21 Pre-Lollipop devices

这篇关于如何在材质设计中更改操作栏的菜单项文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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