How can I modify the style of the items on the Action bar of an Android Application?
I tryed the following:
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="#style/ActionBar">
<item name="android:background">#color/black</item>
<item name="android:actionMenuTextColor">#FF00FF</item>
</style>
The background of the Action bar I was able to modify, but not the text Colors of the items in the Action bar. How can I do it?
EDIT:
I tried pretty much all the android:action attributes I found, but I couldn't manage to change anything other than the background. Only the first <item name="android:background">#FF0000</item> of the following code makes changes on my code. No matter which values I put on the Test style, it doesn't change anything. Why is it happening?
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="#style/ActionBar">
<item name="android:background">#FF0000</item>
<item name="android:actionMenuTextColor">#style/Test</item>
<item name="android:actionButtonStyle">#style/Test</item>
<item name="android:actionModeBackground">#style/Test</item>
<item name="android:actionMenuTextAppearance">#style/Test</item>
</style>
<style name="Test">
<item name="android:textColor">#color/white</item>
<item name="android:background">#FF0000</item>
</style>
If you want to change the color of the menu items in the action bar you have to set the actionMenuTextColor in your theme style.
<style name="PortfolioTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionMenuTextColor">#24598a</item>
<item name="actionMenuTextColor">#24598a</item>
</style>
You don't define the menu item colors in the actionMenuTextAppearance!
You can change the color by:-
<?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.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>
Related
I have an app using the support ActionBarActivity (android.support.v7.app.ActionBarActivity), with tabs. I used the Action Bar Style Generator to change the look of the app, but now I am having a hard time getting the tab text color to change.
The style is being applied through the manifest, and shows up just fine except for the tab text color remains black no matter what I try. Here's what I have in my custom styles xml file right now:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.StyledActionBar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_StyledActionBar</item>
<item name="popupMenuStyle">#style/PopupMenu.StyledActionBar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.StyledActionBar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.StyledActionBar</item>
<item name="actionDropDownStyle">#style/DropDownNav.StyledActionBar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.StyledActionBar</item>
<item name="actionModeBackground">#drawable/cab_background_top_StyledActionBar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_StyledActionBar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.StyledActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
</style>
<style name="TabTextStyle" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_StyledActionBar</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_StyledActionBar</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_StyledActionBar</item>
<item name="progressBarStyle">#style/ProgressBar.StyledActionBar</item>
</style>
<style name="ActionBar.Transparent.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_StyledActionBar</item>
<item name="progressBarStyle">#style/ProgressBar.StyledActionBar</item>
</style>
<style name="PopupMenu.StyledActionBar" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_StyledActionBar</item>
</style>
<style name="DropDownListView.StyledActionBar" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_StyledActionBar</item>
</style>
<style name="ActionBarTabStyle.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_StyledActionBar</item>
</style>
<style name="DropDownNav.StyledActionBar" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_StyledActionBar</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_StyledActionBar</item>
<item name="android:dropDownSelector">#drawable/selectable_background_StyledActionBar</item>
</style>
<style name="ProgressBar.StyledActionBar" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_StyledActionBar</item>
</style>
<style name="ActionButton.CloseMode.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_StyledActionBar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.StyledActionBar.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.StyledActionBar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.StyledActionBar</item>
</style>
</resources>
As you can see, I tried to change the color to white, but to no effect. I also was trying to change the Action Bar title color, but gave up because I found a java workaround.
ActionBarActivity is deprecated.
And you are using Theme.AppCompat : ActionBarActivity is deprecated
Try to use AppCompatActivity in your java codes(Activity).
Does anyone know the way in which i am meant to code the change i want to make to the color of the ActionBar? I have tried using android:textColor , and android:color , as well as various other things. It seems like a quite a hassle for me. Although there is most probably a simple solution for this. Does anyone have any ideas?
Note: i am trying to make the font color white - from what i can tell, Android does this from the "actionbar.solid.pp" style.
<style name="Theme.Pp" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">#drawable/selectable_background_pp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Pp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Pp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Pp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Pp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Pp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_pp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_pp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Pp</item>
</style>
<style name="ActionBar.Solid.Pp" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#111</item>
<item name="android:color">#FFF</item>
<item name="android:textStyle">bold</item>
<item name="android:progressBarStyle">#style/ProgressBar.Pp</item>
</style>
<style name="ActionBar.Transparent.Pp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_pp</item>
<item name="android:progressBarStyle">#style/ProgressBar.Pp</item>
</style>
<style name="PopupMenu.Pp" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_pp</item>
</style>
<style name="DropDownListView.Pp" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_pp</item>
</style>
<style name="ActionBarTabStyle.Pp" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#ffffff</item>
</style>
<style name="DropDownNav.Pp" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/spinner_background_ab_pp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_pp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_pp</item>
</style>
<style name="ProgressBar.Pp" parent="#android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_pp</item>
</style>
<style name="ActionButton.CloseMode.Pp" parent="#android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_pp</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Pp.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Pp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Pp</item>
</style>
Changing the action bar's text color is shown on the developer guide Styling the Action Bar
I think you can use this free tool to customize the style:
http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=holo&theme=light&actionbarstyle=solid&texture=0&hairline=0&neutralPressed=1&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tabColor=33B5E5%2C100&tertiaryColor=F2F2F2%2C100&accentColor=33B5E5%2C100&cabBackColor=FFFFFF%2C100&cabHighlightColor=33B5E5%2C100
I am trying to change the drop down background of the sherlock action bar as well as its text color. Here's what I have tried:
<style name="DropDown" parent="Widget.Sherlock.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#EDEDED</item>
</style>
<style name="TextAppearance" parent="TextAppearance.Sherlock.Widget.TextView.SpinnerItem">
<item name="android:textColor">#A9A9A9</item>
</style>
<style name="SpinnerItemStyle" parent="Widget.Sherlock.TextView.SpinnerItem">
<item name="android:textAppearance">#style/TextAppearance</item>
</style>
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>
The main theme being MyTheme, with the following code I am getting the desirable background color, but I am getting nowhere with the text's color inside the drop down navigation. Can someone please help.
Put that code
<item name="android:textColor">#ffffffff</item>
into your MyTheme code should be like:
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>
I am trying to achieve 2 things
White Text for Menu Items, Title text color works
Text Shadows for Title and Menu item
All this on XML.
What works, after experiments?
Custom Action bar layout works just fine with shadows.
Text color for all Tiles works but text shadow has no effect
Text color for Menu item has no effect anywhere. In the example code when I declare MenuTextStyle in the main Theme tag, I am able to change text size but not color.
<style name="Theme.SexyApp" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarItemBackground">#drawable/list_state</item>
<item name="actionBarItemBackground">#drawable/list_state</item>
<item name="android:actionMenuTextAppearance">#style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
<item name="actionMenuTextAppearance">#style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
</style>
<style name="Widget.SexyApp.ActionBar" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showTitle</item>
<item name="android:titleTextStyle">#style/Theme.SexyApp.ActionBar.TextAppearance</item>
<item name="titleTextStyle">#style/Theme.SexyApp.ActionBar.TextAppearance</item>
</style>
<style name="Theme.SexyApp.ActionBar.TextAppearance" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
<style name="Theme.SexyApp.ActionBar.MenuTextStyle" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">13dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
To change the menu item text color, you need to add the actionMenuTextColor item to your theme style as in the code below:
<style name="ThemeName" parent="#style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
To update the menu item text appearance (color, size, style) you need to make changes at two different places. The following answer is for sherlock.actionbar
1: In your themes.xml file add following lines:
<style name="Theme.Mytheme" parent="#style/Theme.Sherlock">
<item name="android:actionMenuTextAppearance">#style/CustomMenuItem</item> // define custom style in the style.xml file.
<item name="actionMenuTextColor">#color/mycolor</item>
<item name="android:actionMenuTextColor">#color/mycolor</item>
2: In your styles.xml
<style name="CustomMenuItem" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textStyle">normal</item>
<item name="android:textSize">15sp</item>
<item name="android:textAllCaps">false</item>
</style>
I want my Action Bar spinner to display it's text in white (like in google maps app),
but i'm struggling to get there..
i'm trying something like this:
<style name="Mepo.Spinner" parent="#android:style/Widget.Spinner">
<item name="android:spinnerItemStyle">#style/StandardSpinnerItem</item>
<item name="spinnerItemStyle">#style/StandardSpinnerItem</item>
</style>
<style name="StandardSpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textAppearance">#android:color/white</item>
<item name="android:textColor">#android:color/white</item>
</style>
but that has no effect.
I know this his probably been asked but i can't find the right solution.
any ideas?
p.s i'm actually using sherlock action bar if that matters
in the end this is what i did, maybe this will help someone:
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionDropDownStyle">#style/xxx.ActionBar.DropDown.Style</item>
<item name="android:actionDropDownStyle">#style/xxx.ActionBar.DropDown.Style</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#0B2F39</item>
<item name="android:background">#0B2F39</item>
<item name="backgroundSplit">#0B2F39</item>
<item name="android:backgroundSplit">#0B2F39</item>
</style>
<style name="xxx.ActionBar.DropDown.Style" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/abs__spinner_ab_holo_dark</item>
</style>
if you have any remark or corretions i would love to hear them
If you already use an custom theme(you extended the base theme and customized it) and you want to customize the spinner only for one activity you need to do this:
<style name="Theme.MyTheme" parent="Theme.Sherlock">
... your other items
</style>
<style name="Theme.MyTheme.Spinner" parent="Theme.MyTheme">
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>
<style name="Spinner" parent="#android:style/Widget.Spinner">
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>
<style name="SpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="#android:style/Widget.Holo.Light.DropDownItem.Spinner">
<item name="android:textColor">#android:color/white</item>
</style>
And to use this style in an activity use this:
<activity
android:name=".YourActivity"
android:theme="#style/Theme.MyTheme.Spinner" >
</activity>
If you want to customize the spinner for all the activities(your application) move the items from Theme.MyTheme.Spinner into Theme.MyTheme:
<style name="Theme.MyTheme" parent="Theme.Sherlock">
... your other items
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>