In my main theme, I include this:
<item name="android:popupMenuStyle">#style/ListPopupWindow</item>
in styles.xml:
<style name="ListPopupWindow" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:textColor">#color/bright_foreground_holo_dark</item>
</style>
where bright_foreground_holo_dark is a light gray (#fff3f3f3). Yet the text appears as black. The background is a dark gray, as it should be in the dark holo theme.
These definitions are in the android styles.xml source.
<style name="Widget.Holo.ListPopupWindow" parent="Widget.ListPopupWindow">
<item name="android:dropDownSelector">#android:drawable/list_selector_holo_dark</item>
<item name="android:popupBackground">#android:drawable/menu_dropdown_panel_holo_dark</item>
<item name="android:dropDownVerticalOffset">0dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>
<style name="Widget.ListPopupWindow">
<item name="android:dropDownSelector">#android:drawable/list_selector_background</item>
<item name="android:popupBackground">#android:drawable/spinner_dropdown_background</item>
<item name="android:dropDownVerticalOffset">-10dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>
<style name="Widget">
<item name="android:textAppearance">?textAppearance</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">?textColorPrimary</item>
<item name="android:textColorHighlight">?textColorHighlight</item>
<item name="android:textColorHint">?textColorHint</item>
<item name="android:textColorLink">?textColorLink</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
</style>
Just in case someone is looking for help,
To change the font color of overflow menu item, your main theme should include
<item name="android:textAppearanceLargePopupMenu">#style/PopupMenuTextAppearance</item>
and in style.xml
<style name="PopupMenuTextAppearance" parent="android:TextAppearance.Large">
<item name="android:textColor">#color/bright_foreground_holo_dark</item>
</style>
choose any parent TextAppearance.Medium /TextAppearance.Small depending upon needs.
Related
I want to change the color of the overflow icon, menu background color, and text color. The Text color is changing, and I added a new icon but it is bigger than the original and the original is still there. How do I fix the overflow button and change the background color? Thanks in advance.
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="android:actionOverflowMenuStyle">#style/AppTheme.Overflow</item>
<item name="actionOverflowButtonStyle">#style/AppTheme.Overflow</item>
<item name="android:popupMenuStyle">#style/AppTheme.PopupMenu</item>
<item name="android:textAppearanceLargePopupMenu" >#style/AppTheme.TextAppearanceLargePopupMenu</item>
<item name="android:textAppearanceSmallPopupMenu" >#style/AppTheme.TextAppearanceSmallPopupMenu</item>
</style>
<style name="AppTheme.Overflow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:background">#drawable/ic_overflow</item>
</style>
<style name="AppTheme.PopupMenu" parent="Widget.AppCompat.ListPopupWindow">
<item name="android:popupBackground">#color/window_background</item>
</style>
<style name="AppTheme.TextAppearanceLargePopupMenu" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
<item name="android:textColor">#color/light_text</item>
</style>
<style name="AppTheme.TextAppearanceSmallPopupMenu" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
<item name="android:textColor">#color/light_text</item>
</style>
</resources>
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 have used Android Asset Studio to generate action bar style, however i woul like to do some changes, which I was unable to do in Studio, so I edited generated theme but lot of things was just ignored, and I just can't figure out how things work.
There is example:
`
<style name="Theme.Myactionbar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">#style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">#drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_myactionbar</item> //THIS IS GREEN
<item name="backgroundStacked">#drawable/ab_solid_myactionbar</item>//THIS IS GREEN
<item name="backgroundSplit">#drawable/ab_bottom_solid_myactionbar</item>//THIS IS GREEN
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
<style name="ActionBar.Transparent.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_myactionbar</item>
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
<style name="PopupMenu.Myactionbar" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example </item>
</style>
<style name="DropDownListView.Myactionbar" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_myactionbar</item>
</style>
<style name="ActionBarTabStyle.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_myactionbar</item>
</style>
<style name="DropDownNav.Myactionbar" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_myactionbar</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myactionbar</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myactionbar</item>
</style>
<style name="ProgressBar.Myactionbar" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_myactionbar</item>
</style>
<style name="ActionButton.CloseMode.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_myactionbar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Myactionbar.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
</style>
Everything was like in generator, but then i tried the simplest change, that is the color, so I edited style name=ActionBar.Solid.Myactionbar and put there som other drawables from other generated style.
It looked like this :
<style name="Theme.Myactionbar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">#style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">#style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">#drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_example</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_myactionbar</item>
<item name="progressBarStyle">#style/ProgressBar.Myactionbar</item>
</style>
but nothing happend, and changed drawables supposed to be gray. I was wandering if anybody did this before and why this isnt working? Thank you
Ok I figured it out, there is values-v14 folder for styles for api level 14 and above, so you have to change these values too.
In the application I have, I would like to have the actionbar drop down's font to be white. Till now I have the following style:
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.SubTitle" parent="TextAppearance.Sherlock.Widget.ActionBar.Subtitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="titleTextStyle">#style/ActionBar.Title</item>
<item name="subtitleTextStyle">#style/ActionBar.SubTitle</item>
</style>
This style gives me a black colored font in android 3.0 and higher. Can someone please help me configure the font to be white ?
The funny thing about this is that the action overflow popup's font appears in white.
for now I just used the simple
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Its simple but it got the job done. And what got the job done was the change in the style's parent.
You have apply the style to the native ActionBar as well:
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.SubTitle" parent="TextAppearance.Sherlock.Widget.ActionBar.Subtitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="titleTextStyle">#style/ActionBar.Title</item>
<item name="subtitleTextStyle">#style/ActionBar.SubTitle</item>
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:subtitleTextStyle">#style/ActionBar.SubTitle</item>
</style>
I am trying the Theme Sherlock Action Bar. I want to set the color of the Title as White. When i try to do the following the Title disappears all together.
Also I want to change the background color of an Action Item Icon when Pressed.
What i have tried ?
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Variation on the Holo Light theme that styles the Action Bar -->
<style name="Theme.Nomad" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Nomad.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Nomad.ActionBar</item>
<item name="android:actionBarItemBackground">#drawable/actionbar_selectable_background</item>
<item name="actionBarItemBackground">#drawable/actionbar_selectable_background</item>
<item name="android:titleTextStyle">#style/TitleText</item>
<item name="titleTextStyle">#style/TitleText</item>
<!--
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
<item name="popupMenuStyle">#style/MyPopupMenu</item>
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">#style/MyActionBarTabStyle</item>
<item name="actionBarTabStyle">#style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
<item name="actionDropDownStyle">#style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/ad_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">#drawable/ad_btn_radio_holo_light</item>
<item name="android:actionOverflowButtonStyle">#style/MyOverflowButton</item>
-->
</style>
<style name="Widget.Nomad.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#E5492A</item>
<item name="background">#E5492A</item>
</style>
<style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
<item name="textColor">#android:color/white</item>
<item name="android:textSize">18dip</item>
<item name="textSize">18dip</item>
</style>
</resources>
I am not sure about item background, but for text color you can:
add these items in Widget.Nomad.ActionBar (style with parent Widget.Sherlock.ActionBar):
<item name="android:titleTextStyle">#style/TitleText</item>
<item name="titleTextStyle">#style/TitleText</item>
where:
<style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">18sp</item>
</style>
The best solution is this!
actionBar.setTitle(Html.fromHtml("<font color=\"#ffffff\"><b>" + AppName + "</b></font>"));
I promise it will be very helpful! Good luck!