ActionBar Custom Title Color - android

<?xml version="1.0" encoding="utf-8"?>
<style name="OmlActionBarTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/OmlActionBar</item>
<item name="android:homeAsUpIndicator">#drawable/back_arrow</item>
<item name="android:titleTextStyle">#style/OmlActionBarTitle</item>
<item name="android:subtitleTextStyle">#style/OmlActionBarSubTitle</item>
</style>
<style name="OmlActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/action_bar_white</item>
</style>
<style name="OmlActionBarTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/action_bar_blue</item>
</style>
<style name="OmlActionBarSubTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
<item name="android:textColor">#color/action_bar_blue</item>
</style>
Hi,I need to customize my actionBar title Text Color and subTitle Text Color. I used the above style but there is no change.

Try The Following...
style.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowBackground">#drawable/login_background</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/theme_blue</item>
<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>
</style>
</resources>
Apply this theme to your application in Manifest File..
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_icon128"
android:label="#string/app_name"
android:theme="#style/AppTheme" // apply theme here
android:windowSoftInputMode="stateHidden" >

i have done with simple one line code
actionBar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBartitle </font>"));

Related

AppCompat Custom theme not applying

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.

Android action bar's title color not changing

I would like to change the contextual action bar's title text color and back button colour.
Please find the code i am using, still i couldn't able to achieve
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:actionModeBackground">#color/dark_blue_Shade1</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
Please help me to fix
</style>
<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>
<item name="android:subtitleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#0061C2</item>
<item name="android:icon">#android:color/transparent</item><!--hiding the icon ..in case you want it..-->
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
and in the manifest ...you can apply this theme for your app
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme" ><!--this is that theme-->
or just to one of your activities
<activity
android:name="eddine.charef.mechalikh.swipedemo.MainActivity"
android:label="#string/mainActivity"
android:theme="#style/MyTheme"
>
that's all
Edit: i found this in android developpers website
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
<!-- ActionBar tabs text -->
<style name="MyActionBarTabText"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
</resources>
here is the link https://developer.android.com/training/basics/actionbar/styling.html

Android styles: how to change colors in styles.xml

I want to change some colors of android UI elements. But I would prefer to set a default tint color, which applies to all UI elements. I am not sure if this is possible.
If not, I want to set the "tint"-color of some UI elements, as shown below. Can anybody enlighten me?
EDIT
Based on what Entreco suggested:
My styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:textColorPrimary">#color/brown</item>
<item name="android:textColorSecondary">#color/brown</item>
<item name="android:textColorTertiary">#color/brown</item>
<item name="android:textColorPrimaryInverse">#color/brown</item>
<item name="android:textColorSecondaryInverse">#color/brown</item>
<item name="android:textColorTertiaryInverse">#color/brown</item>
<item name="colorPrimary">#color/blue</item>
<item name="colorPrimaryDark">#color/blue</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#color/brown</item>
<item name="titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="background">#color/brown</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/brown_light</item>
<item name="android:textSize">24sp</item>
</style>
</resources>
And my values-v21/styles.xml:
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/blue</item>
<item name="android:colorPrimaryDark">#color/blue</item>
<!-- <item name="android:colorAccent">#color/white</item> -->
</style>
</resources>
And in my Manifest:
<application android:theme="#style/AppTheme.Base" >
...
</application>
But the primary color is still the same...???
Starting from Lollipop this is straight-forward thanks to the colorPrimary attribute:
file values/styles.xml:
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
</style>
file values-v21/styles.xml:
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/white</item>
</style>
Basically, you can define a color pallete for your app, and I believe for your case your want to set the colorPrimary (unverified).
More info on Material colors

When dynamically changing theme colourPrimaryDark is not taking effect

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);

Android: Title Bar Color don't change

I wanna change my Apps Titlebar color and tried it in this way:
Part of the manifest file:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/Theme.MyTitleBar" ></application>
The style block part of the file styles.xml:
<style name="Theme.MyTitleBar" parent="android:Theme">
<item name="android:colorBackground">#FFFFFF</item>
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
But only the text color and attributes changes correct. Any guest what I did wrong?
EDIT: I added the part for the ActionBar (sorry I put only for Dialogs at first)
You can follow this, it will allow you to change moreover other attributes that just the title bar:
Just call your custom theme in the manifest file:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Then create these 2 styles in your styles.xml. The first one defines the theme, the second one, one of the styles to apply on the theme:
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:colorBackground">#FFFFFF</item>
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
NOTE: In this example, I customize the theme Holo Light as you can see with this: android:style/Widget.Holo.Light.ActionBar.
Add This style.xml File in your project according to your requirment...
<item name="android:actionBarStyle">#style/myActionBar</item>
</style>
<style name="myActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:titleTextStyle">#style/myActionBar.titleTextStyle</item>
</style>
<style name="myActionBar.titleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse">
<item name="android:textColor">#color/darkgrey</item>
</style>
<style name="myActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#e6ebc3</item>
</style>

Categories

Resources