Search code examples
androidandroid-actionbarmaterial-components-android

Unable to change colour of ActionBar Title Text


I have this style:

<resources>

    <style name="ThemeTest.BaseTheme.Light" parent="@style/Theme.MaterialComponents.Light">

        <item name="android:actionBarStyle">@style/ThemeTest.Widget.ActionBar</item>
    </style>

    <style name="ThemeTest.Widget.ActionBar" parent="@style/Widget.MaterialComponents.ActionBar.Solid">

        <item name="android:titleTextStyle">@style/ThemeTest.Widget.ActionBar.Title</item>
    </style>

    <style name="ThemeTest.Widget.ActionBar.Title" parent="@style/TextAppearance.MaterialComponents.Headline6">

        <item name="android:textColor">@color/clear_white</item>
    </style>
</resources>

It is supposed to show the actionbar title text (my app's name, by default) in clear white colour (#ffffff). But it does nothing. I can't make out any difference between the above style and this:

<resources>

    <style name="ThemeTest.BaseTheme.Light" parent="@style/Theme.MaterialComponents.Light">

    </style>
</resources>

They look identical (the app name is in black).

I have tried several combinations of styles and widgets, but nothing seems to work.

The dependency is com.google.android.material:material:1.3.0-alpha01.

What am I missing?


Solution

  • If you are using an ActionBar you can use:

    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
        <item name="actionBarTheme">@style/ThemeOverlay.Actionbar</item>
    </style>
    

    with:

    <style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.ActionBar.Surface" >
            <item name="android:textColorPrimary">@color/....</item>
    </style>
    

    enter image description here