8

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:

the problem

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?

le0m
  • 398
  • 1
  • 4
  • 14

3 Answers3

23
<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

dhpratik
  • 1,100
  • 4
  • 19
  • 43
JavierSegoviaCordoba
  • 6,531
  • 9
  • 37
  • 51
  • How do i implement these properties based on API level? – le0m Feb 02 '15 at 01:48
  • You can create a style file for each api level. Just copy and paste the styles files in the same folder and in the dialog add -v19 (for example) – JavierSegoviaCordoba Feb 02 '15 at 01:49
  • Doesn't work. Changing 'android:textColorPrimary' changes the item text color, but this also changes the actionbar title text color. – le0m Feb 02 '15 at 02:10
  • 1
    You should take a look this post https://www.google.es/url?sa=t&source=web&rct=j&ei=F93OVIv3C4GkULjwgNAF&url=http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html%3Fm%3D1&ved=0CCcQFjAB&usg=AFQjCNHsqPPBTDdJhCTY6fsUf601KBes0g&sig2=q8QFDvXNq8H8M7monLAiag – JavierSegoviaCordoba Feb 02 '15 at 02:12
  • 1
    And this: http://www.murrayc.com/permalink/2014/10/28/android-changing-the-toolbars-text-color-and-overflow-icon-color/ – JavierSegoviaCordoba Feb 02 '15 at 02:15
  • You mean i should switch to using a ToolBar? – le0m Feb 02 '15 at 02:38
  • 2
    Yes, you should switch. You can solve your problem following that two posts if you use toolbar. – JavierSegoviaCordoba Feb 02 '15 at 02:40
  • Ok, i'll accept as answer because you provided couple of nice tutorials, but please add 'read comments' to answer. – le0m Feb 02 '15 at 02:49
  • and next step we have to do is to this style in our toolbar for theme and popuptheme attributes – Himanshu Mori May 07 '18 at 10:01
9

Below worked for me

<item name="actionMenuTextColor">yourColor</item>
<item name="android:actionMenuTextColor">yourColor</item>
sanjeev barnwal
  • 851
  • 8
  • 3
1

Below work for me fine.

<item name="android:textColor">your color</item>
Pedek
  • 11
  • 2