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
I think it is just the problem of you activity.I used the same code as you, and it works.
Firstly ,i used AppCompatActivity as the base activity and get error. and then i use activity and it works. In my opinion, your code is use for theme for Theme.Holo, and now we use Theme.AppCompat . So if you want change, just reference Changing Background and text color of AppCompat Light DarkActionBar Theme on android. It works for me.Good luck for you.
Seems you've used
style
instead oftheme
. Styles and themes differ. So replaceWith
wandering around StackOverflow I found this answer which finally worked.
I report it here:
You could find how to customize
ActionBar
here. I recommend to useToolBar
andTheme.AppCompat
instead - example.Just add
app:titleTextColor="@color/CUSTOM_COLOR"
like so:I am assuming you are using
ToolBar
asActionBar
. Of all the answers, I think this is the easiest one to implement. And works on all API versions.So here it is:
Action bar title uses
textColorPrimary
as its text color. So to change that in styles.xml create a new style with an item fortextColorPrimary
and set whatever color you need.Now, add that style as your theme for toolbar in the XML.
And now you got what you need.