Search code examples
androidtabslowercase

Android tab titles lowercase


maybe not a big deal, but I can't get this to work. I have a tab navigation, and I am taking the tab titles from strings.xml as an array:

 String[] tbTitles= resources.getStringArray(R.array.tabname);

    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab()
                        .setText(tbTitles[i])
                        .setTabListener(this));
    }
}

The tabnames are defined as lowercase (or better to say Capitalized - Example). It is working fine, but the issue is on older API's, where every tab title is uppercase.

I went through some solutions on this forum, but didn't find any solution.

I tried to put this in my for loop:

 tbTitles[i] = tbTitles[i].toLowerCase();

I also tried to put this to my tablayout style in styles.xml:

 <item name="textAllCaps">false</item>

The text is always Uppercase on older androids. Of course it is working for the newer API's.

All I want is to Capitalize the titles also for older API's.


Solution

  • As no solution worked for me, finally I solved it like this:

    In my styles.xml to <style name="Base.Widget.Design.TabLayout" parent="@android:style/Theme.Holo">

    i just put

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

    and then below:

     <style name="My.TabText.Style" parent="@android:style/Widget.Holo.ActionBar.TabText">
        <item name="android:textAllCaps">false</item>
    </style>
    

    This is the only solution that works for me!

    So the point was to add android:actionBarTabTextStyle and not tabTextAppearance