0

How to change menu item's text background while clicking on it? The higlight color on whole item is right, but it seems that text has it's own background color. I think that deal is in settin on app:popupTheme, but I don't know what style parameters I should set.

enter image description here

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
user3352926
  • 1,017
  • 1
  • 10
  • 15

2 Answers2

0

Kindly Use this and set the desired color.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.your_menu, menu);

    int positionOfMenuItem = 0; // or whatever...
    MenuItem item = menu.getItem(positionOfMenuItem);
    SpannableString s = new SpannableString("My MenuItem");
    s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
    item.setTitle(s);
}
Fathima km
  • 2,539
  • 3
  • 18
  • 26
0

Please check How to change the background color of Action Bar's Option Menu in Android 4.2?

check image

and for change text color : Setting the "android:textColor" will work

<style name="AppTheme.ActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
        ...
        <!--This would set the menu item color-->
        <item name="android:textColor">#000</item>
        ...
 </style>
Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142