I don't want to create any custom layout for app label, just want to change it's color to white (now it's black). How could I do that?
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/bg_blue_solid_onclick</item>
//////CHANGE label color
</style>
</resources>
styles.xml
<style name="MyTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
For more info
https://developer.android.com/training/basics/actionbar/styling.html#CustomText
Snap
Edit : For making it bold
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
<item name="android:textStyle">bold</item>
</style>
None of the previous answers worked for me, so I'm showing the one that worked in my case.
<style name="AppThemeCustom" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#android:color/black</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:windowBackground">#android:color/white</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/black</item>
</style>
I wish if you find yourself in my situation this solution save your day. LOL
You need to style the android:titleTextStyle in your ActionBar.
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/MyTextTitle</item>
</style>
<style name="MyTextTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
You can see this in Android Documentation: Customize the Text Color in ActionBar
Hope this helps.
in styles.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
in toolbar
android:theme="#style/AppTheme.AppBarOverlay"
Related
Hello can any one help me in this how to change the overflow icon to white colour I have tried a lot but it is not coming here is my code can any one help me. Help will be appreciated. Here is the code I think so their is only a minor mistake I'am unable find the mistake please help me.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:textAppearance">#style/MyTheme.ActionBar.Text</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#336699</item>
<item name="android:actionOverflowButtonStyle">#style/MyTheme.ActionBar.OverFlow</item>
</style>
<style name="MyTheme.ActionBar.OverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/menu</item>
</style>
<style name="MyTheme.ActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">25dp</item>
</style>
<style name="myTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/myTheme.ActionBar</item>
<item name="android:actionMenuTextColor">#ffffff</item>
</style>
<style name="myTheme.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#336699</item>
<item name="android:actionOverflowButtonStyle">#style/myTheme.ActionBar.OverFlow</item>
<item name="android:titleTextStyle">#style/myTheme.ActionBar.Text</item>
</style>
<style name="myTheme.ActionBar.OverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/menu</item>
</style>
<style name="myTheme.ActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textSize">23dip</item>
<item name="android:fontFamily">sans-serif-condensed</item>
<item name="android:textColor">#ffffff</item>
</style>
</resources>
Make your theme dark:
<style name="MyTheme" parent="#android:style/Theme.Holo.Dark">
or you can change the actionbar theme instead:
<style name="MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
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 want to change the title text color of the ActionBar in my app. I have tried in many ways but I can't achieve it. I don't want to do it programatically because when the app is launched it shows the action bar with previous color and then changes to the new one. I'm supporting from Api Level 8 and my xml was generated with the Android Action Bar Style Generator. Then I tried to change the title text color with this . The title text color is still black.
This is my code:
<resources>
<style name="Theme.Dbtools_style" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_dbtools_style</item>
<item name="popupMenuStyle">#style/PopupMenu.Dbtools_style</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Dbtools_style</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Dbtools_style</item>
<item name="actionDropDownStyle">#style/DropDownNav.Dbtools_style</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Dbtools_style</item>
<item name="actionModeBackground">#drawable/cab_background_top_dbtools_style</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_dbtools_style</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Dbtools_style</item>
<!-- Remove icon in Action Bar -->
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/ActionBar.Solid.Dbtools_style</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_dbtools_style</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_dbtools_style</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_dbtools_style</item>
<item name="progressBarStyle">#style/ProgressBar.Dbtools_style</item>
<!-- Title Text Color -->
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="ActionBar.Transparent.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_dbtools_style</item>
<item name="progressBarStyle">#style/ProgressBar.Dbtools_style</item>
</style>
<style name="PopupMenu.Dbtools_style" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_dbtools_style</item>
</style>
<style name="DropDownListView.Dbtools_style" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_dbtools_style</item>
</style>
<style name="ActionBarTabStyle.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_dbtools_style</item>
</style>
<style name="DropDownNav.Dbtools_style" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_dbtools_style</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_dbtools_style</item>
<item name="android:dropDownSelector">#drawable/selectable_background_dbtools_style</item>
</style>
<style name="ProgressBar.Dbtools_style" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_dbtools_style</item>
</style>
<style name="ActionButton.CloseMode.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_dbtools_style</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Dbtools_style.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Dbtools_style</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Dbtools_style</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
I solved my problem. The problem was that I was testing in a device with api level 14+ and I just added the style to res/values . I had to add the style in res/values-v14 too. I attach my code:
res/values/styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Dbtools_style" parent="#style/Theme.AppCompat.Light">
<!-- Title Text Color -->
<item name="actionMenuTextColor">#color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text Color -->
<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>
res/values-v14/styles.xml
<style name="Theme.Dbtools_style" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBar.Solid.Dbtools_style</item>
<!-- Title Text Color -->
<item name="android:actionMenuTextColor">#color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text color -->
<item name="android: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>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
You Have to do two things:
Styles.xml
<style name="MyTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
Colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
This link might help you out with the appropriate color you want.
This link is also helpful.
Set titletextstyle and subtitletextstyle too ...
This is what worked for me. ..
If you want to change that using xml ...
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>
for me this one worked.
go to /value/colors.xml
add <color name="black">#000000</color> //if you want black to your <resources>
to to /values/styles.xml
add <item name="titleTextColor">#color/black</item> to your <style>
here is some example code, too:
color.xml:
<resources>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#03DAC5</color>
<color name="black">#000000</color>
</resources>
styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="titleTextColor">#color/black</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>
<style name="Theme.RateItTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
</style>
<style name="MyActionBar.Text" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ECECEC</item>
</style>
I have been able to change the background, but not the text color. Or the overflow menu "three dots". My code is above.
You need to move your titleTextStyle attribute into your MyActionBar style. Do you understand why it's supposed to be placed there rather than where you had it originally?
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
As far as changing the Overflow icon, I think that's what mean when you say "three dots", I've already written a post about that here.
Try this
<?xml version="1.0" encoding="utf-8"?>
<!-- For honeycomb and up -->
<resources>
<style name="Theme.RateItTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor">#color/actionBarText</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
<style name="MyActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#ECECEC</item>
</style>
</resources>