美文网首页
TabLayout 设置文本小写 textAllCaps = f

TabLayout 设置文本小写 textAllCaps = f

作者: Kingsley_Wu | 来源:发表于2020-10-21 18:27 被阅读0次

    如是support 包下的TabLayout 则设置:

    <style name="TabLayoutStyle" parent="Widget.Design.TabLayout">
        <item name="tabMaxWidth">@dimen/tab_max_width</item>
        <item name="tabIndicatorColor">@color/black</item>
        <item name="tabIndicatorHeight">2dp</item>
        <item name="tabPaddingStart">8dp</item>
        <item name="tabPaddingEnd">8dp</item>
        <item name="tabBackground">?attr/selectableItemBackground</item>
        <item name="tabTextAppearance">@style/TabTextAppearance</item>
        <item name="tabSelectedTextColor">@android:color/white</item>
    </style>
    
    <style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
        <item name="android:textSize">14sp</item>
        <item name="android:textColor">@color/white</item>
        <item name="textAllCaps">false</item>
    </style>
    
    <android.support.design.widget.TabLayout
        style="@style/TabLayoutStyle"
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    

    如是com.google.android.material.tabs.TabLayout 包下的TabLayout 则设置:

    <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>
    
    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tab_layout"
        style="@style/customTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    

    或:

    <style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
        <item name="textAllCaps">false</item>
    </style>
    
    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tab_layout"
        app:tabTextAppearance="@style/TabTextAppearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    

    相关文章

      网友评论

          本文标题:TabLayout 设置文本小写 textAllCaps = f

          本文链接:https://www.haomeiwen.com/subject/jnpemktx.html