TabLayout Tab Title text in Lower Case

血红的双手。 提交于 2019-11-27 18:16:50
Mustanser Iqbal

If you add the following line to your TabLayout it should work:

app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"

Use it like this:

<android.support.design.widget.TabLayout
                    android:id="@+id/tabLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabIndicatorColor="@android:color/white"
                    app:tabIndicatorHeight="2dp"
                    app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
                    app:tabSelectedTextColor="@android:color/white"
                    app:tabTextColor="@android:color/white" />

You can just customize and make your title using below code,

 <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabIndicatorColor="@color/colorLightPink"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@color/colorLightPink"
    app:tabTextAppearance="@style/CustomTextAppearanceTab"
    app:tabTextColor="@color/colorGreyDark" /> 

CustomTextAppearanceTab defines the text style which is written in style.xml file

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

you can customize your tab title with color as well as Lower case by using below code

<android.support.design.widget.TabLayout
    android:id="@+id/sliding_tabs"
    style="@style/customTabLayout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/tabHeight"
    android:background="@color/blurred_black"
    android:divider="@drawable/blue"
    android:stretchColumns="*"
    app:tabMode="fixed" />

customTabLayout is style which is written in style.xml file

<style name="customTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabIndicatorColor">@color/default_back</item>
    <item name="tabIndicatorHeight">2dp</item>
    <item name="tabPaddingStart">12dp</item>
    <item name="tabPaddingEnd">12dp</item>
    <item name="textAllCaps">false</item>
    <item name="android:dividerPadding">3dp</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">@color/default_back</item>
    <item name="android:divider">@android:color/black</item>
    <item name="tabBackground">?attr/selectableItemBackground</item>
    <item name="tabSelectedTextColor">@color/default_back</item>
</style>

Hope will help it out in other way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!