Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change AppBar text color in my theme (AppCompat)?

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?

like image 996
Mikhail Avatar asked Oct 28 '25 07:10

Mikhail


2 Answers

  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.

like image 169
daxgirl Avatar answered Oct 31 '25 07:10

daxgirl


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

like image 25
Utkarsh Singh Avatar answered Oct 31 '25 08:10

Utkarsh Singh