how to change actionbar's menu item text color in material design

ぃ、小莉子 提交于 2020-01-13 11:59:07

问题


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

What i did so far:

  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>
    

The problem:

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?


回答1:


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

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

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

Above is the code for API < v21

Some tutorials:

Changing toolbar's text color and overflow icon color

Appcompat v21 Pre-Lollipop devices




回答2:


Below worked for me

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


来源:https://stackoverflow.com/questions/28267502/how-to-change-actionbars-menu-item-text-color-in-material-design

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!