1

I tried set title color but it is deprecated. I tried to change color by using

  <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
  </style>

  <style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
  </style>

  <style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>
  </style>

as mentioned here: ActionBar text color but the whole Titlebar color changes to white while doing it. All I want to do is set my Black Title bar text color to white. I also tried this solution here: Change color title bar but I am using the MaterialComponents theme and using AppCompactThemes makes my app crash.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841

2 Answers2

5

Assuming that you are not using a Toolbar the textcolor used in the ActionBar is based on the attribute android:textColorPrimary.
You can override it adding in your app theme the actionBarTheme attribute:

<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

As alternative you can

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
3

just add this to you base theme

 <item name="titleTextColor">@android:color/holo_red_dark</item> //whatever color

Eg:

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="titleTextColor">@android:color/holo_green_dark</item>

    </style>
hemen
  • 1,460
  • 2
  • 16
  • 35