4

I want to change only the AppBar text color, but in the Theme Editor (I use Android Studio) I can only change textColorPrimary (it changes AppBar text color but also the LargeText color).

My current theme: enter image description here

I can change only textColorPrimary: enter image description here

Now I change the text color like this:

style.xml

<resources>

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

</resources>

activity.xml

...
<android.support.design.widget.AppBarLayout
        ...
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
           ...
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

        ...

</android.support.design.widget.AppBarLayout>

Is it possible to change text color in my AppTheme in style.xml?

Hawken MacKay Rives
  • 1,171
  • 1
  • 16
  • 26
Mikhail
  • 2,612
  • 3
  • 22
  • 37

2 Answers2

3
  1. Create a custom theme which has as parent your desired base theme, such as ThemeOverlay.AppCompat.Dark.ActionBar.
  2. Add customizations to the theme. For title color it will be textColorPrimary. For overflow and icons it will be textColorSecondary.

Then use the custom theme you created to set theme for your toolbar.

Toufic Batache
  • 762
  • 10
  • 24
daxgirl
  • 762
  • 4
  • 10
  • 1
    does not work. I have set textColor, titleTextColor, and android:textColorPrimary to black but the title is still white. – Code Wiget Mar 25 '20 at 00:07
2

@color/colorForeground

You can just add "colorForeground" attribute in styles for changing the foreground color in appbar. This also changes the text colour and the color of the menu dots.

Or you can use the theme editor to edit the colors.

Utkarsh Singh
  • 59
  • 1
  • 2