How to change action bar submenu item style of menu - android

my action bar;
<item
android:id="#+id/userMenuItem"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText">
<menu>
<item android:id="#+id/logout"
android:title="#string/logout"
android:showAsAction="ifRoom|withText" />
</menu>
</item>
and style.xml ;
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextAppearance">#style/MyActionBar.MenuTextStyle</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBar.TitleTextStyle</item>
<item name="android:background">#drawable/action_bar_style</item>
</style>
<style name="MyActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#191970</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">24sp</item>
</style>
question is how to change logout item style like font size, color ext.
<item name="android:actionMenuTextAppearance">#style/MyActionBar.MenuTextStyle</item>
is working for menu items style but i can't change submenu style.

You can change the reference of android:listViewStyle in order to change your submenu list layout. If you want in your Light theme the menu from the dark version of Holo you can write:
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextAppearance">#style/MyActionBar.MenuTextStyle</item>
<item name="android:listViewStyle">#android:style/Widget.Holo.ListView</item>
</style>
Of course you can assign your own style with adjusted font. This will change only the drop down menu.

Related

Set overflow menu text color

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.

Actionbar Sherlock Change Title Color

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!

Applying shadow and text color for Title and Menu Item in Sherlock Action bar

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>

Action Bar Sherlock dropdown spinner divider

How can I hide dividers in action bar dropdown menu navigation?
Here is divider which I want to hide:
http://s10.postimage.org/4sjqjxltl/4nk4k.png
I tried following in styles:
<style name="MyActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:background">#drawable/actionbar_bg_shape</item>
<item name="background">#drawable/actionbar_bg_shape</item>
<item name="android:showDividers">none</item>
<item name="android:divider">#00000000</item>
<item name="android:cacheColorHint">#00000000</item>
<item name="android:dividerHeight">0px</item>
</style>
<style name="MyDropDownNav" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:textColor">#FFFFFF</item>
<item name="android:background">#drawable/actionbar_bg_shape</item>
<item name="android:popupBackground">#drawable/actionbar_dropdown_bg_shape</item>
<item name="android:dropDownSelector">#drawable/dropdown_nav_selector</item>
<item name="android:dropDownWidth">175dp</item>
<item name="android:dropDownHeight">50dp</item>
<item name="android:showDividers">none</item>
<item name="android:divider">#null</item>
<item name="android:cacheColorHint">#00000000</item>
<item name="android:dividerHeight">0px</item>
<item name="background">#drawable/actionbar_bg_shape</item>
</style>
<style name="Theme.Test.ICS" parent="Theme.Sherlock.Light">
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
<item name="actionDropDownStyle">#style/MyDropDownNav</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarDivider">#drawable/icon</item>
<item name="android:actionBarDivider">#drawable/icon</item>
</style>
I've also tried with changing divider property to color or drawable.
But divider is still present in dropdown menu navigation, no effect at all. Any ideas would be really helpful.
You need to extend the Widget.Sherlock.ListView.DropDown style like this:
<style name="Theme.YourTheme" parent="Theme.Sherlock">
<item name="dropDownListViewStyle">#style/YourThemeDropDownListView</item>
<item name="android:dropDownListViewStyle">#style/YourThemeDropDownListView</item>
</style>
<style name="YourThemeDropDownListView" parent="Widget.Sherlock.ListView.DropDown">
<item name="android:divider">#null</item>
</style>
It's worth to note, that divider Height must be specified to edit divider's color.
<style name="YourThemeDropDownListView" parent="Widget.Sherlock.ListView.DropDown">
<item name="android:divider">#color/White</item
<item name="android:dividerHeight">5dp</item>
</style>

Modify style of Android items in the ActionBar

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>

Categories

Resources