I want to change the title text color of the ActionBar in my app. I have tried in many ways but I can\'t achieve it. I don\'t want to do it programatically because when the app
I solved my problem. The problem was that I was testing in a device with api level 14+ and I just added the style to res/values . I had to add the style in res/values-v14 too. I attach my code:
res/values/styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Dbtools_style" parent="@style/Theme.AppCompat.Light">
<!-- Title Text Color -->
<item name="actionMenuTextColor">@color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text Color -->
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
res/values-v14/styles.xml
<style name="Theme.Dbtools_style" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/ActionBar.Solid.Dbtools_style</item>
<!-- Title Text Color -->
<item name="android:actionMenuTextColor">@color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text color -->
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
Set titletextstyle and subtitletextstyle too ... This is what worked for me. ..
If you want to change that using xml ... This is what worked for me ...
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/titleBarBgColor</item>
<item name="android:titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<!-- Support library compatibility -->
<item name="background">@color/titleBarBgColor</item>
<item name="titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="EldTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/titleBarTextColor</item>
</style>
You Have to do two things:
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
This link might help you out with the appropriate color you want. This link is also helpful.
for me this one worked.
<color name="black">#000000</color> //if you want black
to your <resources>
<item name="titleTextColor">@color/black</item>
to your <style>
here is some example code, too: color.xml:
<resources>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#03DAC5</color>
<color name="black">#000000</color>
</resources>
styles.xml:
<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">@color/black</item>
</style>```