美文网首页
自定义Tablayout下划线宽度

自定义Tablayout下划线宽度

作者: 奔波儿灞_q | 来源:发表于2019-11-22 16:03 被阅读0次

不用反射,不用设置customView

先设置这两个属性,其中app:tabIndicator, 再support包28以上才有,
颜色只用通过app:tabIndicatorColor 属性设置,

 app:tabIndicator="@drawable/tab_indictor_bg"
  app:tabIndicatorColor="@color/colorPrimary"

tab_indictor_bg文件内容;

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <item android:gravity="center">
        <shape >
            <size
                //下划线宽度
                android:width="20dp"
                android:height="2dp" />
            <corners android:radius="4dp" />
        </shape>
    </item>
</layer-list>

相关文章

网友评论

      本文标题:自定义Tablayout下划线宽度

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