How to style ActionaBar Tab text in Android?

11,300

Solution 1

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>
    

Solution 2

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/

Share:
11,300
Amit
Author by

Amit

"Be a good person, but never try to prove it." #SOreadytohelp I am a professional programmer and a Certified Scrum Master (CSM) currently working as Full Stack Java Developer. Technical Skills Java (Core and Advaced), Spring Security, MicroServices, AWS, C, C++, Android, JSP, JavaScript, jQuery, AngularJS, HTML,JSP, PL/SQL, Hibernate etc. Areas of Interest Any kind of programming, R &amp; D which pays enough money Java based Application Development i.e. Core Java, J2EE, J2ME, JNI, Web Development Software designing and Solution analysis for cloud plateforms. Have knowledge of AWS architecture but can work on Azure or Google cloud too if case 1 above is true :). Web Services and Microservices Development. Web application security and related frameworks and projects like prevention against OWASP's Top 10 vulnerabilities. Algorithm optimization, fine tuning, research &amp; development.

Updated on June 11, 2022

Comments

  • Amit
    Amit almost 2 years

    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