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>
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).
I am trying to style the TabBar using the following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base"/>
<style name="MyTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">#color/palette_1</item>
<item name="colorPrimaryDark">#color/palette_5</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="android:windowBackground">#color/palette_1</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
<item name="android:actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
</style>
<style name="MyTheme.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/palette_5</item>
<item name="backgroundStacked">#color/palette_5</item>
<item name="backgroundSplit">#color/palette_5</item>
</style>
<style name="MyTheme.ActionBarTabBar" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#color/palette_5</item>
</style>
<style name="MyTheme.NoTitleBar" parent="MyTheme">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
Whewre palette_1 is green and palette_5 is blue for example.
The actionBar is blue but the tabbar stays the color that i define in android:windowBackground, which is green.
This is the code i came up with after searching numerous topics. But yet it seems to be conflicting somewhere.
I have a Sherlock Action Bar with Theme DarkActionBar so I can get the white search Icon in the Action Bar.
But, when I did that the submenu of my contextMenu (that is decided with a popUp - like an AlertDialog) the theme of this dialog is being dark like its parent, and I want it Light.
How should I do that? Get the white search icon (dark theme) and the Light theme for the context menu option ?
This is my styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="StyledIndicators" parent="#style/Theme.SherlockCustom">
<item name="vpiTabPageIndicatorStyle">#style/CustomTabPageIndicator</item>
<item name="vpiTabTextStyle">#style/CustomTabPageIndicator.Text</item>
</style>
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">#drawable/custom_tab_indicator</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="Widget.TabPageIndicator.Text">
<item name="android:textColor">#FF555555</item>
</style>
<style name="CustomTheme.TitleActionBar" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="CustomTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
<item name="background">#drawable/gradiente_titlebar</item>
<item name="android:background">#drawable/gradiente_titlebar</item>
<item name="titleTextStyle">#style/CustomTheme.TitleActionBar</item>
<item name="android:titleTextStyle">#style/CustomTheme.TitleActionBar</item>
</style>
<style name="Theme.SherlockCustom" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/CustomTheme.ActionBarStyle</item>
<item name="android:actionBarStyle">#style/CustomTheme.ActionBarStyle</item>
<item name="spinnerDropDownItemStyle">#style/Theme.Sherlock.Light</item>
<item name="android:spinnerDropDownItemStyle">#style/Theme.Sherlock.Light</item>
<item name="spinnerItemStyle">#style/Theme.Sherlock.Light</item>
<item name="android:spinnerItemStyle">#style/Theme.Sherlock.Light</item>
<item name="popupMenuStyle">#style/Theme.Sherlock.Light</item>
<item name="android:popupMenuStyle">#style/Theme.Sherlock.Light</item>
<item name="actionDropDownStyle">#style/Theme.Sherlock.Light</item>
<item name="android:actionDropDownStyle">#style/Theme.Sherlock.Light</item>
<item name="android:alertDialogStyle">#style/Theme.Sherlock.Light</item>
</style>
</resources>
Found the answer at https://stackoverflow.com/a/15219098/1574617.
Just added that to code so now I can decide which widget search I want to use.
Thanks ASP for answer.
<style name = "Theme.SherlockCustom" parent = "#style/Theme.Sherlock.Light">
<item name = "actionBarWidgetTheme"> #style/Theme.Sherlock.Light.DarkActionBar </item>
<item name = "android:actionBarWidgetTheme"> #style/Theme.Sherlock.Light.DarkActionBar </item>
<item name = "actionBarStyle"> #style/CustomTheme.ActionBarStyle </item>
<item name = "android:actionBarWidgetTheme"> #style/CustomTheme.ActionBarStyle </item>
</style>
Thanks ASP for answer.
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.
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!