Android ActionBar Text Color - android

I have xml like this:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="MyActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#800000</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#000099</item>
</style>
</resources>
Background color is properly set, but title color does not change. Where did I make mistake?
Thanks!

Change it to this:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#800000</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#000099</item>
</style>
</resources>

You can also change programmatically like this
ActionBar actionbar = getSupportedActiobar();
actionBar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBarTitle </font>"));

I'm using this
<resources>
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/myTheme.ActionBar</item>
<item name="actionMenuTextColor">#color/action_text_color</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme"></style>
<style name="myTheme.ActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="titleTextStyle">#style/myTheme.ActionBar.Text</item>
<item name="background">#drawable/abc_tab_indicator_ab_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_transparent_dark_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_transparent_light_holo</item>
</style>
<style name="myTheme.ActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/action_text_color</item>
</style>

This is what worked for me ...
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/titleBarBgColor</item>
<item name="android:titleTextStyle">#style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">#style/EldTheme.ActionBar.TitleTextStyle</item>
<!-- Support library compatibility -->
<item name="background">#color/titleBarBgColor</item>
<item name="titleTextStyle">#style/EldTheme.ActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">#style/EldTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="EldTheme.ActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/titleBarTextColor</item>
</style>

Related

Change color of menu font on ActionBar

I wish to change the color of the menu font:
<!-- Base application theme. -->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/dark_gray</item>
<item name="android:color">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
but the menu font color is still black. What item should I add/remove?
Try this instead
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
Use this Style
<style name="MyTheme" parent="Theme.Sherlock.ForceOverflow">
<item name="android:actionBarWidgetTheme">#style/MyActionWidgetTheme</item>
<item name="actionBarWidgetTheme">#style/MyActionWidgetTheme</item>
</style>
<style name="MyActionWidgetTheme" parent="Widget">
<item name="android:textColor">#f00</item>
</style>

How to change Action Mode's color and text

I want to Change Action mode background and title color in it . i tried this But nothing has changed
Here is my styles.xml file
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>
<style name="LiveoActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/LiveoActionBar</item>
</style>
<style name="LiveoActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="titleTextStyle">#style/Liveo.TitleTextStyle</item>
<item name="subtitleTextStyle">#style/Liveo.SubTitleTextStyle</item>
<item name="background">#color/green_google_play</item>
</style>
<style name="Liveo.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textStyle">normal</item>
</style>
<style name="Liveo.SubTitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">#color/white</item>
<item name="android:textStyle">normal</item>
</style>
<style name="menu_labels_style">
<item name="android:background">#drawable/fab_label_background</item>
<item name="android:textColor">#color/white</item>
</style>
</resources>
Update your code as follows and try ,
<style name="LiveoActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/LiveoActionBar</item>
</style>
<style name="LiveoActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/Liveo.TitleTextStyle</item>
<item name="android:subtitleTextStyle">#style/Liveo.SubTitleTextStyle</item>
<item name="android:background">#color/green_google_play</item>
</style>

Unable to change text color of ActionBar title

I am unable to change the text color of title of Action Bar. How can it be done in xml itself?
My style.xml in values-v11 and values-v14 contain this snippet of code
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
</style>
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showTitle</item>
<item name="titleTextStyle">#style/titleStyle</item>
</style>
<style name="titleStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#f2dca9</item>
</style>
</resources>
please try this. it works
you, put this code in the onCreate() method
ActionBar bar = getActionBar();
bar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBartitle </font>"));
or Add it to the root of the action bar
<style name="ActionBar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionMenuTextColor">#color/stdDarkBlueText</item>
</style>
<style name="Widget.Styled.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">#style/ActionBarTitleText</item>
<item name="subtitleTextStyle">#style/ActionBarSubTitleText</item>
</style>
<style name="ActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/stdDarkBlueText</item>
<item name="android:textSize">12sp</item>
</style>
<style name="ActionBarSubTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">#color/stdDarkBlueText</item>
<item name="android:textSize">12sp</item>
try this
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:displayOptions">showTitle</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#f2dca9</item>
</style>
Do it programmatically,
int titleId = this.activity.getResources().getIdentifier("action_bar_title", "id", "android");
TextView abTitle = (TextView) this.activity.findViewById(titleId);
abTitle.setTextColor(Color.parseColor("#6f6f6f"));
using XML:
<resources>
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:titleTextStyle">#style/TitleBarTextColor</item>
</style>
<style name="TitleBarTextColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
if you use API 14 and UP then put it into values-v14.....
Thats it...

Android. ActionBar. How to change ActionBar title color?

I am trying to change ActionBar title color. I tried different ways to do it. But I could not solve this problem. I have created my own actionbar theme in values/styles.xml and values-14/styles.xml
values/styles.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/grey_actionbar_background</item>
<item name="icon">#drawable/ic_launcher</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
</style>
<style name="MyActionBarTabText" parent="#style/Widget.AppCompat.Light.ActionBar.TabText">
<item name="android:textColor">#color/grey_text</item>
</style>
values-v14/styles.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/grey_actionbar_background</item>
<item name="background">#color/grey_actionbar_background</item>
<item name="android:icon">#drawable/ic_launcher</item>
<item name="icon">#drawable/ic_launcher</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
</style>
<style name="MyActionBarTabText" parent="#style/Widget.AppCompat.Light.ActionBar.TabText">
<item name="android:textColor">#color/grey_text</item>
</style>
grey_text color is #58585A. But when I am running on 4.3 device, ActionBar title color is F3F3F3.
I am wondering why this is happening. How to solve this problem?
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
...
</style>
<style name="ActionBar" parent="#android:style/Widget.ActionBar">
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:subtitleTextStyle">#style/ActionBar.Subtitle</item>
...
</style>
<style name="ActionBar.Title">
<item name="android:textColor">#color/my_color</item>
</style>
<style name="ActionBar.Subtitle">
<item name="android:textColor">#color/my_color</item>
</style>
just try method of Activity class "setTitleColor(int color)"

Title in ActionBar appears black

I am having trouble finding out why the title in my action bar appears black, this only happens on an emulator with Android 4.1.1, which should be API 15.
Here is my default styles.xml
<resources>
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
and here is the styles from values-v15 and values-v14
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionOverflowButtonStyle">#style/OverFlow</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- Styles -->
<style name="OverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_action_about</item>
<item name="android:textColor">#color/white</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/action_bar_background</item>
<item name="android:textColor">#color/white</item>
</style>
what would be the problem?
Try this:
<style name="TitleTextColor">
<item name="android:text">#string/app_name</item>
<item name="android:textSize">10sp</item>
<item name="android:textColor">#a23421</item>
</style>
Edit:(new) Put this in the styles.XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle"parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
</resources>
For White text:
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#f00</item>
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>

Categories

Resources