Change color of menu font on ActionBar - android

I wish to change the color of the menu font:
<!-- Base application theme. -->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/dark_gray</item>
<item name="android:color">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
but the menu font color is still black. What item should I add/remove?

Try this instead
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>

Use this Style
<style name="MyTheme" parent="Theme.Sherlock.ForceOverflow">
<item name="android:actionBarWidgetTheme">#style/MyActionWidgetTheme</item>
<item name="actionBarWidgetTheme">#style/MyActionWidgetTheme</item>
</style>
<style name="MyActionWidgetTheme" parent="Widget">
<item name="android:textColor">#f00</item>
</style>

Related

Change text color in toolbar / action bar, android?

I want to change the text color and the navigation icon color in the toolbar
Change the text color of the action item "13311"
And also of the drawer icon.
The styles
//activity theme
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="colorPrimaryDark">#color/ColorPrimaryDark</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="switchStyle">#style/Switch</item>
</style>
//theme for switch widget
<style name="Switch" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="android:thumb">#drawable/switch_selector</item>
<item name="showText">false</item>
</style>
//toolbar theme
<style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:gravity">center_vertical</item>
<!--<item name="popupTheme">#style/PopupMenuStyle</item>-->
<item name="actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
//overflow menu theme
<style name="PopupMenuStyle" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/black</item>
<item name="android:gravity">left|center</item>
<item name="android:background">#color/white</item>
</style>
//action button theme
<style name="MyActionButtonStyle" parent="AppBaseTheme">
<item name="android:minWidth">0dip</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
<style name="MyDarkToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<!-- text color for action menu icons -->
<item name="android:textColorSecondary">#fff</item>
<!-- overflow menu icon color -->
<item name="actionMenuTextColor">#fff</item>
</style>
Edit
To change the navigation drawer color use
<style name="DrawerStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/drawer_color</item>
</style>
change the parent theme to darkactionbar
when the action bar is dark you will get your icon and text white , when it is light you will get them black .
that's all
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
To change arrow color I used colorControlNormal
from AppTheme and AppTheme.ActionBarTheme
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="windowActionBar">false</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">#android:color/white</item>
<item name="actionBarTheme">#style/AppTheme.ActionBarTheme</item>
<item name="android:itemTextAppearance">#style/ToolbarTextAppearance</item>
<!-- Material Theme -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/accent_color</item>
<item name="android:statusBarColor" tools:targetApi="21">#color/statusBarColor</item>
<item name="android:navigationBarColor" tools:targetApi="21">#color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="AppTheme.ActionBarTheme" parent="#style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">#android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/drawerArrowColor</item>
</style>
<style name="ToolbarTextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>

Android. ActionBar. How to change ActionBar title color?

I am trying to change ActionBar title color. I tried different ways to do it. But I could not solve this problem. I have created my own actionbar theme in values/styles.xml and values-14/styles.xml
values/styles.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/grey_actionbar_background</item>
<item name="icon">#drawable/ic_launcher</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
</style>
<style name="MyActionBarTabText" parent="#style/Widget.AppCompat.Light.ActionBar.TabText">
<item name="android:textColor">#color/grey_text</item>
</style>
values-v14/styles.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/grey_actionbar_background</item>
<item name="background">#color/grey_actionbar_background</item>
<item name="android:icon">#drawable/ic_launcher</item>
<item name="icon">#drawable/ic_launcher</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
</style>
<style name="MyActionBarTabText" parent="#style/Widget.AppCompat.Light.ActionBar.TabText">
<item name="android:textColor">#color/grey_text</item>
</style>
grey_text color is #58585A. But when I am running on 4.3 device, ActionBar title color is F3F3F3.
I am wondering why this is happening. How to solve this problem?
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
...
</style>
<style name="ActionBar" parent="#android:style/Widget.ActionBar">
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:subtitleTextStyle">#style/ActionBar.Subtitle</item>
...
</style>
<style name="ActionBar.Title">
<item name="android:textColor">#color/my_color</item>
</style>
<style name="ActionBar.Subtitle">
<item name="android:textColor">#color/my_color</item>
</style>
just try method of Activity class "setTitleColor(int color)"

Title in ActionBar appears black

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>

Change ActionBar OverflowMenu Background color

Ive added a lot of properties to change to background color of the overflow menu, none seem to work.
Here are a few links i've refered (other than SO questions):
http://blog.stylingandroid.com/archives/1267
http://android-developers.blogspot.in/2011/04/customizing-action-bar.html
res>values>
style.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
</style>
<style name="MyPopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#28bda9</item>
<item name="android:titleTextStyle">#style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#28bda9</item>
</style>
<!-- style the items within the overflow menu -->
<style name="MyDropDownListView" parent="android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#28bda9</item>
</style>
<!-- style the list navigation -->
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#28bda9</item>
<item name="android:popupBackground">#28bda9</item>
<item name="android:dropDownSelector">#28bda9</item>
</style>
</resources>
Edit: I have changed the code to match the solution. This was the error:
<style name="MyPopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">**#28bda9**</item>
</style>
You're on the right track, but the popupBackground is not merely a color.
You have to change the drawable.
Below is the default drawable for Holo Light (usually called menu_dropdown_panel).
Change the color using your favorite image editor, and put it your drawable-x folder.
The needed style will be as follows:
<style name="AppTheme" parent="AppBaseTheme">
...
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
</style>
<style name="MyPopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel</item>
</style>

Android ActionBar Text Color

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>

Categories

Resources