美文网首页
Tablayout自定义下划线样式

Tablayout自定义下划线样式

作者: 河马过河 | 来源:发表于2020-10-20 15:13 被阅读0次
        <com.google.android.material.tabs.TabLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/dp_56"
                app:tabBackground="@drawable/selector_tab_indicator"
                app:tabIndicatorHeight="@dimen/dp_0"
                app:tabMode="fixed"
                app:tabSelectedTextColor="@color/color_FF4089"
                app:tabTextAppearance="@style/CustomTabLayoutTextAppearance"
                app:tabTextColor="@color/color_141414" />
        <style name="CustomTabLayoutTextAppearance" parent="android:TextAppearance.Widget.TabWidget">
            <item name="android:textAllCaps">false</item>
            <item name="android:textSize">@dimen/sp_16</item>
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">@color/color_white</item>
        </style>
    

    selector_tab_indicator

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/shape_tab_indicator_selected" android:state_checked="true"/>
    <item android:drawable="@drawable/shape_tab_indicator_selected" android:state_pressed="true"/>
    <item android:drawable="@drawable/shape_tab_indicator_selected" android:state_selected="true"/>
    <item android:drawable="@drawable/shape_tab_indicator" />
    </selector>
    

    shape_tab_indicator_selected

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape>
                <solid android:color="@color/color_white" />
            </shape>
        </item>
        <item
            android:top="@dimen/dp_52"
            android:gravity="bottom|center_horizontal">
            <shape>
                <solid android:color="@color/color_FF4089" />
            </shape>
        </item>
    </layer-list>
    

    shape_tab_indicator

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape>
                <solid android:color="@color/color_white" />
            </shape>
        </item>
        <item     android:top="@dimen/dp_52"
            android:gravity="bottom|center_horizontal">
            <shape>
                <solid android:color="@color/color_FFE2ED" />
            </shape>
        </item>
    </layer-list>
    

    相关文章

      网友评论

          本文标题:Tablayout自定义下划线样式

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