With the Material Components Library you can use the app:titleTextColor
attribute.
In the layout you can use something like:
<com.google.android.material.appbar.MaterialToolbar
app:titleTextColor="@color/...."
.../>
You can also use a custom style:
<com.google.android.material.appbar.MaterialToolbar
style="@style/MyToolbarStyle"
.../>
with (extending the Widget.MaterialComponents.Toolbar.Primary
style) :
<style name="MyToolbarStyle" parent="Widget.MaterialComponents.Toolbar.Primary">
<item name="titleTextColor">@color/....</item>
</style>
or (extending the Widget.MaterialComponents.Toolbar
style) :
<style name="MyToolbarStyle" parent="Widget.MaterialComponents.Toolbar">
<item name="titleTextColor">@color/....</item>
</style>
You can also override the color defined by the style using the android:theme
attribute (using the Widget.MaterialComponents.Toolbar.Primary
style):
<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">
<!-- This attributes is also used by navigation icon and overflow icon -->
<item name="colorOnPrimary">@color/...</item>
</style>
or (using the Widget.MaterialComponents.Toolbar
style):
<com.google.android.material.appbar.MaterialToolbar
style="@style/Widget.MaterialComponents.Toolbar"
android:theme="@style/MyThemeOverlay_Toolbar2"
with:
<style name="MyThemeOverlay_Toolbar3" 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>