Just use the MaterialToolbar
and override the default colors:
<com.google.android.material.appbar.MaterialToolbar
style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:theme="@style/MyThemeOverlay_Toolbar"
..>
with:
<style name="MyThemeOverlay_Toolbar" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
<!-- color used by navigation icon and overflow icon -->
<item name="colorOnPrimary">@color/...</item>
</style>
If you are using the androidx.appcompat.widget.Toolbar
or the MaterialToolbar
with the default style (Widget.MaterialComponents.Toolbar
) you can use:
<androidx.appcompat.widget.Toolbar
android:theme="@style/MyThemeOverlay_Toolbar2"
with:
<style name="MyThemeOverlay_Toolbar2" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
<!-- This attributes is used by title -->
<item name="android:textColorPrimary">@color/white</item>
<!-- This attributes is used by navigation icon and overflow icon -->
<item name="colorOnPrimary">@color/secondaryColor</item>
</style>