How to set title color in ActionBarSherlock
?
Which theming attributes should I use?
You can easily do this with
getSupportActionBar().setTitle(Html.fromHtml("<font color='#ffffff'>App Name</font>"));
From the ActionBarSherlock website
Parent Themes
In order for the custom action bar implementation to function your application must use Theme.Sherlock, Theme.Sherlock.Light, or Theme.Sherlock.Light.DarkActionBar, or your custom theme must use one of the aforementioned as its parent.
Mirrored Attributes
Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation...
In short, that means you need to leave out the android:
prefix when you're styling the ActionBar
.
Theming the title color
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YOURTHEME" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">@style/YOURTHEME.ActionBarStyle</item>
<item name="actionBarStyle">@style/YOURTHEME.ActionBarStyle</item>
</style>
<style name="YOURTHEME.ActionBarStyle" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:titleTextStyle">@style/YOURTHEME.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/YOURTHEME.ActionBar.TitleTextStyle</item>
</style>
<style name="YOURTHEME.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">@color/YOUR_COLOR</item>
<item name="textColor">@color/YOUR_COLOR</item>
</style>
</resources>
NOTE
I haven't tested this. Also, what have you tried? You should searching before posting on SO in the future.
i have changed the title color of this way:
in the Styles.xml file, i have added these styles
<style name="Theme.Styled" parent="@style/Theme.Sherlock.Light">
<item name="actionBarStyle">@style/CustomActionBarStyle</item>
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
<item name="titleTextStyle">@style/CustomTitleColorBar</item>
<item name="android:titleTextStyle">@style/CustomTitleColorBar</item>
</style>
<!-- Style for the color title bar -->
<style name="CustomTitleColorBar" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
</style>
the last thing that i did was set the theme in the activity:
public static int THEME = R.style.Theme_Styled;
this line goes before super.onCreate() method
setTheme(THEME);
this is it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With