I have an application which needs to apply different themes on user's choice. So, I have created the themes. These themes are working fine when applied through the Manifest.xml. But when I try to programmatically change the themes, only ActionBar colour is getting changed and the status bar colour remains same like the theme I have applied in Manifest.xml. My codes are in below. I already tried all the available resources but failed to find any solution.
Thanks in advance.
themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--<Cyan Theme Configuration>-->
<style name="Theme.Cyan" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary_color_cyan_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_cyan_variant</item>
<item name="colorAccent">#color/accent_color_for_cyan_variant</item>
<item name="android:icon">#drawable/ic_launcher</item>
</style>
<style name="Theme.Cyan.ToolBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color_cyan_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_cyan_variant</item>
<item name="colorAccent">#color/accent_color_for_cyan_variant</item>
</style>
<style name="Theme.Cyan.ToolBarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/primary_color_cyan_variant</item>
<item name="android:textColor">#FFF</item>
<item name="android:textColorSecondary">#color/primary_color_dark_cyan_variant</item>
</style>
<!--<Blue Theme Configuration>-->
<style name="Theme.Blue" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary_color_blue_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_blue_variant</item>
<item name="colorAccent">#color/accent_color_for_blue_variant</item>
<item name="android:icon">#drawable/ic_launcher</item>
</style>
<style name="Theme.Blue.ToolBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color_blue_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_blue_variant</item>
<item name="colorAccent">#color/accent_color_for_blue_variant</item>
</style>
<style name="Theme.Blue.ToolBarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/primary_color_blue_variant</item>
<item name="android:textColor">#FFF</item>
<item name="android:textColorSecondary">#color/primary_color_dark_blue_variant</item>
</style>
<!--<Teal Theme Configuration>-->
<style name="Theme.Teal" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary_color_teal_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_teal_variant</item>
<item name="colorAccent">#color/accent_color_for_teal_variant</item>
<item name="android:icon">#drawable/ic_launcher</item>
</style>
<style name="Theme.Teal.ToolBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color_teal_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_teal_variant</item>
<item name="colorAccent">#color/accent_color_for_teal_variant</item>
</style>
<style name="Theme.Teal.ToolBarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/primary_color_teal_variant</item>
<item name="android:textColor">#FFF</item>
<item name="android:textColorSecondary">#color/primary_color_dark_teal_variant</item>
</style>
<!--<Green Theme Configuration>-->
<style name="Theme.Green" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary_color_green_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_green_variant</item>
<item name="colorAccent">#color/accent_color_for_green_variant</item>
<item name="android:icon">#drawable/ic_launcher</item>
</style>
<style name="Theme.Green.ToolBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color_green_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_green_variant</item>
<item name="colorAccent">#color/accent_color_for_green_variant</item>
</style>
<style name="Theme.Green.ToolBarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/primary_color_green_variant</item>
<item name="android:textColor">#FFF</item>
<item name="android:textColorSecondary">#color/primary_color_dark_green_variant</item>
</style>
<!--<BlueGrey Theme Configuration>-->
<style name="Theme.BlueGrey" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary_color_blueGrey_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_blueGrey_variant</item>
<item name="colorAccent">#color/accent_color_for_blueGrey_variant</item>
<item name="android:icon">#drawable/ic_launcher</item>
</style>
<style name="Theme.BlueGrey.ToolBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color_blueGrey_variant</item>
<item name="colorPrimaryDark">#color/primary_color_dark_blueGrey_variant</item>
<item name="colorAccent">#color/accent_color_for_blueGrey_variant</item>
</style>
<style name="Theme.BlueGrey.ToolBarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:background">#color/primary_color_blueGrey_variant</item>
<item name="android:textColor">#FFF</item>
<item name="android:textColorSecondary">#color/primary_color_dark_blueGrey_variant</item>
</style>
</resources>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Green">
<!-- Customize your theme here. -->
</style>
<style name="Ocean" parent="Theme.Cyan"/>
<style name="Sky" parent="Theme.Blue"/>
<style name="Peacock" parent="Theme.Teal"/>
<style name="AppTheme.Grass" parent="Theme.Green"/>
<style name="Shadow" parent="Theme.BlueGrey"/>
<style name="menu_labels_style">
<!--<item name="android:background">#drawable/fab_label_background</item>-->
<item name="android:textColor">#color/white</item>
</style>
</resources>
Manifest.xml
<application
android:name="com.compassites.employeedirectory.EmployeeDirectoryApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
MainActivity.java
super.onCreate(savedInstanceState);
setTheme(R.style.Ocean);
setContentView(R.layout.activity_main);
Call set theme before super.onCreate
i.e.
setTheme(R.style.Ocean);
super.onCreate(savedInstanceState);
Related
I have a problem with my holo theme, it works right until Android 4.4 but when i run the same app in Android 5.0+ the dropdown menu for overflow items in the actionbar show the TEXT in color Black, i need the color WHITE
ANY IDEAS?
<style name="Theme.Flux" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_flux</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Flux</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Flux</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Flux</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_flux</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_flux</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Flux</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Flux.Widget</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid.Flux" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_solid_flux</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_flux</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_flux</item>
<item name="android:progressBarStyle">#style/ProgressBar.Flux</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Transparent.Flux" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_flux</item>
<item name="android:progressBarStyle">#style/ProgressBar.Flux</item>
</style>
<style name="PopupMenu.Flux" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_flux</item>
</style>
<style name="DropDownListView.Flux" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_flux</item>
</style>
<style name="ActionBarTabStyle.Flux" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_flux</item>
</style>
<style name="DropDownNav.Flux" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_flux</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_flux</item>
<item name="android:dropDownSelector">#drawable/selectable_background_flux</item>
</style>
<style name="ProgressBar.Flux" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_flux</item>
</style>
<style name="ActionButton.CloseMode.Flux" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_flux</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Flux.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
</style>
<style name="menu_labels_style">
<item name="android:background">#drawable/fab_label_background</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
Change the style file also in values-v11 and values-v14 folders
i solve my problem when i put my style file in values-v11 and values-v14 folders i also add this style to my main style.
<item name="android:itemTextAppearance">#style/TextAppearance</item>
this is my style
<style name="Theme.Flux" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_flux</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Flux</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Flux</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Flux</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_flux</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_flux</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Flux</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Flux.Widget</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>
I generated a custom theme using the Android Asset Studio Actionbar styling tool. I am not able to view the theme. I only get the AppCompat.Light or AppCompat.Light.DarkActionBar base theme in my app. (I also referred to this article Theme not applied using appcompat library on some Android 4.X devices)
My values/styles.xml
<style name="Theme.Betbuds" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_betbuds</item>
<item name="popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Betbuds</item>
<item name="actionDropDownStyle">#style/DropDownNav.Betbuds</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Betbuds</item>
<item name="actionModeBackground">#drawable/cab_background_top_betbuds</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_betbuds</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Betbuds</item>
</style>
<style name="ActionBar.Solid.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_betbuds</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_betbuds</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_betbuds</item>
<item name="progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="ActionBar.Transparent.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_betbuds</item>
<item name="progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="PopupMenu.Betbuds" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_betbuds</item>
</style>
<style name="DropDownListView.Betbuds" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_betbuds</item>
</style>
<style name="ActionBarTabStyle.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_betbuds</item>
</style>
<style name="DropDownNav.Betbuds" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_betbuds</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_betbuds</item>
<item name="android:dropDownSelector">#drawable/selectable_background_betbuds</item>
</style>
<style name="ProgressBar.Betbuds" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_betbuds</item>
</style>
<style name="ActionButton.CloseMode.Betbuds" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_betbuds</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Betbuds.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
</style>
My values-v14/styles.xml
<style name="Theme.Betbuds" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_betbuds</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Betbuds</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Betbuds</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Betbuds</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_betbuds</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_betbuds</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Betbuds</item>
</style>
<style name="ActionBar.Solid.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_betbuds</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_betbuds</item>
<item name="android:backgroundSplit">#drawable/ab_solid_betbuds</item>
<item name="android:progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="ActionBar.Transparent.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_betbuds</item>
<item name="android:progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Betbuds.Widget" parent="#style/Theme.AppCompat">
<item name="android:popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
</style>
</resources>
The Android Studio preview also shows only the Base themes. I have the following in my Manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Betbuds" >
I realise that there are a lot of questions similar to this. I am not able to figure out an answer. Any help is appreciated. Thanks.
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>
I try to change text color and size of my actionbar through the style resources:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Example3" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">#drawable/selectable_background_example3</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Example3</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example3</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Example3</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Example3</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Example3</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_example3</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_example3</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example3</item>
</style>
<style name="ActionBar.Solid.Example3" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_example3</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example3</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_example3</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example3</item>
</style>
<style name="Theme.Example3.ActionBar.Solid.Example3.TitleTextStyle" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#color/white</item>
</style>
<style name="ActionBar.Transparent.Example3" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_example3</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example3</item>
</style>
<style name="PopupMenu.Example3" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example3</item>
</style>
<style name="DropDownListView.Example3" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example3</item>
</style>
<style name="ActionBarTabStyle.Example3" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example3</item>
</style>
<style name="DropDownNav.Example3" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/spinner_background_ab_example3</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example3</item>
<item name="android:dropDownSelector">#drawable/selectable_background_example3</item>
</style>
<style name="ProgressBar.Example3" parent="#android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example3</item>
</style>
<style name="ActionButton.CloseMode.Example3" parent="#android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_example3</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example3.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Example3</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example3</item>
</style>
</resources>
The above style.xml contains following code part, which should change text color and size, but it happens nothing on my actionbar:
<style name="Theme.Example3.ActionBar.Solid.Example3.TitleTextStyle" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#color/white</item>
</style>
What is wrong?
Thanks!!
<item name="android:titleTextStyle">#style/Theme.Example3.ActionBar.Solid.Example3.TitleTextStyle</item>
is missing in <style name="ActionBar.Solid.Example3">
The problem is that you need to link the third block of style from inside the second block of style:
<style name="ActionBar.Solid.Example3" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_example3</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example3</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_example3</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example3</item>
<item name="android:titleTextStyle">#style/Theme.Example3.ActionBar.Solid.Example3.TitleTextStyle</item>
</style>
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>