0

As I'm very new to Android UIs, I'm currently spending a little too much time trying to put a different color on an item (button) of a toolbar.

enter image description here

I want the "Clear" button to get white. Here is the code for the toolbar menu

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">
    <item
        android:id="@+id/actionClear"
        android:orderInCategory="100"
        android:title="@string/clear"
        app:showAsAction="always" />
    <item
        android:id="@+id/actionCheck"
        android:icon="@drawable/ic_check"
        android:orderInCategory="300"
        android:title="@string/done"
        app:showAsAction="ifRoom" />
</menu>

In my styles.xml, I have the following:

<style name="Theme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="toolbarStyle">@style/Theme.Toolbar</item>
</style>

<style name="Theme.Toolbar" parent="Widget.MaterialComponents.Toolbar">
    <item name="android:background">@color/kaki_light</item>
    <item name="titleTextColor">@color/white</item>
    <item name="titleTextAppearance">@style/Theme.Toolbar.TitleAppearance</item>
</style>

I've tried lots of things but I'm unsure how to identify the menu item.

Thanks a lot!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
lorenzo
  • 1,487
  • 1
  • 17
  • 25
  • Possible duplicate of [How to change the Text color of Menu item in Android?](https://stackoverflow.com/questions/3519277/how-to-change-the-text-color-of-menu-item-in-android) – ADM Apr 03 '19 at 09:29

1 Answers1

0

try this create this theme

@color/white

@color/white

Or try this

@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

inflater.inflate(R.menu.your_menu, menu);

int positionOfMenuItem = 0; 

MenuItem item = menu.getItem(positionOfMenuItem);

SpannableString s = new SpannableString("My red MenuItem");

s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);

item.setTitle(s);

}