Search code examples
androidxmlmaterial-designandroid-tablayout

android:textAllCaps=“false” not working for com.google.android.material.tabs.TabLayout


I have set android:textAllCaps="false" in my com.google.android.material.tabs.TabItem thought it is showing the Tab Title in All caps only.

How can I remove all caps?

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <com.google.android.material.tabs.TabItem
        android:id="@+id/TabWeekly"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="@string/Weekly"
        android:textAllCaps="false"
        android:theme="@style/CustomTextAppearanceTab" />

    <com.google.android.material.tabs.TabItem
        android:id="@+id/TabMonthly"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="@string/Monthly"
        android:textAllCaps="false"
        android:theme="@style/CustomTextAppearanceTab" />

</com.google.android.material.tabs.TabLayout>

even I have set style for it

<style name="CustomTextAppearanceTab" parent="TextAppearance.Design.Tab">
       <item name="textAllCaps">false</item>
       <item name="android:textAllCaps">false</item>
</style>

but its not working


Solution

  • custom style

      <style name="customTabLayout" parent="Widget.Design.TabLayout">
        <item name="tabTextAppearance">@style/TabTextAppearance</item>
    </style>
    
    <style name="TabTextAppearance" parent="@android:style/TextAppearance.Widget.TabWidget">
        <item name="android:textAllCaps">false</item>
    </style>
    

    tab layout xml code

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tab"
        style="@style/customTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />