Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to achieve 2 things

  1. White Text for Menu Items, Title text color works
  2. Text Shadows for Title and Menu item

All this on XML.

What works, after experiments?

  1. Custom Action bar layout works just fine with shadows.
  2. Text color for all Tiles works but text shadow has no effect
  3. 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>
    
like image 812
Siddharth Menon Avatar asked Jul 17 '12 11:07

Siddharth Menon


1 Answers

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>
like image 56
Kenyon Tu Avatar answered Sep 30 '22 20:09

Kenyon Tu