问题
I'm trying to update my notepad app to use Material Design, even on older devices.
What i did so far:
- add library appcompat_v7 to my project, to support Material Design on older devices
- modify theme in AndroidManifest, adding
android:theme="@style/Theme.NoteItTheme"
to<application ... ></application>
attributes 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