Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Change Actionbar Title Text Color

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

like image 467
jack_the_beast Avatar asked Nov 13 '15 17:11

jack_the_beast


People also ask

How do you change the color of your title on Android?

in your style. xml in values folder this will change your action bar color.. Replace #666666 with your selected color code for title background color and replace #000000 for your title text color.

How do I change the color of my text messages on Android?

Open your device's Settings app . Text and display. Select Color correction. Turn on Use color correction.

How do I change the color of my status bar text?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.


Video Answer


2 Answers

Using SpannableString we can set Text Color of Actionbar title

SpannableString s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(Color.GREEN), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
getSupportActionBar().setTitle(s);
like image 119
Parag Chauhan Avatar answered Sep 19 '22 12:09

Parag Chauhan


<style name="AppTheme" parent="android:style/Theme.Holo.Light">

<style name="AppTheme.TextView" parent="android:Widget.TextView">

You missed a symbol "@" here?

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

also

<style name="AppTheme.TextView" parent="@android:Widget.TextView">
like image 30
panda Avatar answered Sep 19 '22 12:09

panda