Search code examples
androidandroid-toolbar

How to change color of menu icon on custom action bar?


Im using custom theme:

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

I want to change colors of all icons and label on my appbar to white, but cant do this because my theme is light and if I write DayNight like this parent="Theme.AppCompat.DayNight.NoActionBar"it will not change anything.

I have already changed label text color by java code

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(myToolbar);
        myToolbar.setTitleTextColor(Color.parseColor("#ffffff"));

but I still cant figure out how to change this icon with three horizontal dots color. Anyone can help me to solve this problem?


Solution

  • First, define a style that sets colorControlNormal, making sure to derive from one of the ThemeOverlay styles:

    <style name="MyTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
        <item name="colorControlNormal">@color/your_color_here</item>
    </style>
    

    Then, apply this style to your toolbar in your layout:

    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:theme="@style/MyTheme"/>