Skip to content Skip to sidebar Skip to footer

How To Change Sherlock Action Bar Text Color Programatically?

How can you change the tab text color of the action bar from Java code? Not switching to a different theme that was defined in an XML file, but something like .setTextColor(Color.

Solution 1:

Figured it out.... You can pass in a SpannableString:

SpannableStringspannable=newSpannableString(myString);
spannable.setSpan(newForegroundColorSpan(Color.GREEN), 0, myString.length(), 0);
myTextView.setText(spannable);

Maybe with the standard action bar this is enough (haven't tried), but for Sherlock you also need to set it statically in xml as Sam answered. Otherwise, Sherlock seemed to ignore the span color. It doesn't matter what color you set in the xml since the span color will be used instead.

Solution 2:

I don't believe there is a method that controls this. However read this question: ActionBar text color

The best answer has a popular comment by Jake Wharton, ActionBar Sherlock is his project, and as he says: "This is the correct way."

Post a Comment for "How To Change Sherlock Action Bar Text Color Programatically?"