Applying shadow and text to the title and menu item in the Sherlock action bar

I am trying to achieve two things

  • White text for menu items, text text color
  • Text shadows for title and menu item

All this in XML.

What works after the experiments?

  • The layout of the custom action bar works fine with shadows.
  • The text color for all tiles works, but the shadow of the text has no effect.
  • The text color for the menu item is not valid anywhere. In the sample code, when I declare MenuTextStyle in the main theme tag, I can resize the text, but not the 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> 
+6
source share
2 answers

To change the text color of a menu item, you need to add an actionMenuTextColor element 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> 
+12
source

To update the appearance of the menu text (color, size, style), you need to make changes in two different places. The following answer is for sherlock.actionbar

1: In the themes.xml file, add the 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> 
+1
source

Source: https://habr.com/ru/post/920677/


All Articles