I'm developing an app and I want to change the textcolor of the actionbar title
. now, I defined a theme in my manifest:
<application
android:theme="@style/AppTheme">
</application>
which is defined in styles.xml:
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
<item name="android:textViewStyle">@style/AppTheme.TextView</item>
<item name="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="AppTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/themeapp</item>
</style>
<style name="AppTheme.TextView" parent="@android:style/Widget.TextView">
<item name="android:textColor">#FFFFFF</item>
</style>
this doesn't work but I don't get why. this should work according to this answer.neither the textview style is working.
what I am doing wrong?
UPDATE: changed to meet Grace Feng answer below
Change the
Activity
theme as:When i got the same problem, i used:
I don't know the solution, but I was able to change the text color between white and black with this method.
so, in the styles.xml you have:
if you change what's inside the parent="..." to dark or light themes, it adapts the text color to these themes. For example, right now you have a dark theme, and the text is white, but when I change to "Theme.AppCompat.Light" the text color turns black.
Hope it helps in some way.
Just had this problem, finally figured it out. In your style.xml do not specify a background color for your toolbar. Then define the color in each layout.xml file:
This gives you the flexibility to be able to easily have different action bar colors depending on the activity if need be as well.
You missed a symbol "@" here?
also
Using
SpannableString
we can set Text Color ofActionbar title