Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style ActionaBar Tab text in Android?

I am using ActionBarShrelock to provide Action Bars for pre honeycomb devices. I have following code in my themes.xml file...

 <style name="My.Tab.Style" parent="@android:style/Widget.TabWidget">
        <item name="android:textAppearance">@style/MyCustomTabTextStyle</item>
    </style>

   <style name="MyCustomTabTextStyle" parent="Widget.Sherlock.ActionBar.TabText">
        <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
        <item name="android:textSize">14sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/tabbar_text_color</item>
    </style>

Than I use this it as

<item name="android:actionBarTabTextStyle">@style/My.Tab.Style</item>
<item name="actionBarTabTextStyle">@style/My.Tab.Style</item>

Can any one explain why I am getting some shadow on the last letters of Tab ? How can I get rid of that ? plz help.. I have tried everything but that shadow is always there..

enter image description here

like image 221
Amit Avatar asked Oct 12 '12 10:10

Amit


2 Answers

I solved the problem using a custom style.

  1. First I created a custom style

    <style name="My.TabText.Style" parent="@style/Widget.Sherlock.ActionBar.TabText">       
        <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
        <item name="android:textSize">16sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/tabbar_text_color</item>
        <item name="android:textAllCaps">false</item>
        <!-- <item name="android:ellipsize">none</item> --> 
        <item name="android:maxLines">1</item>
    </style>
    
  2. Than i used that style in my Theme

    <item name="actionBarTabTextStyle">@style/My.TabText.Style</item>
    <item name="android:actionBarTabTextStyle">@style/My.TabText.Style</item>
    
like image 57
Amit Avatar answered Nov 01 '22 21:11

Amit


As far as I know ActionBar Shelock uses the same from the normal action bar. Based on that assumption:

a previous answer I gave ActionBar text color

and a generator http://jgilfelt.github.com/android-actionbarstylegenerator/

like image 1
Budius Avatar answered Nov 01 '22 21:11

Budius