Search code examples
androidmaterial-designandroid-toolbarandroid-color

How can I change color of items on Toolbar


I have a Toolbar, I want to change background to Black but by default items color is black and I want to change their color to gray, how can I do that ? Thanks you so much: My Image about Toolbar

And this is my toolbar.xml

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2196F3"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

My styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Solution

  • While creating an icon or vector asset, you can select the color

    enter image description here

    Click on the color selector.

    If you want to change color in code then add app:iconTint="@color/yourcolor" in your MenuItem for change the Icon color.

    <item
    android:icon="@drawable/ic_share_white_24dp"
    android:id="@+id/action_share"
    android:title="@string/action_share"
    android:orderInCategory="200"
    app:iconTint="@color/yourcolor"
    app:showAsAction="ifRoom"
    app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>
    

    For changing the 3 dots icon color, try adding this in styles.xml

    <style name="YourCustomTheme.OverFlow">
        <item name="android:src">@drawable/my_overflow_image</item>
    </style>