美文网首页
TabLayout设置下划线宽度(非反射)

TabLayout设置下划线宽度(非反射)

作者: 懒猫1105 | 来源:发表于2018-09-27 09:58 被阅读0次

Android 9.0对非SDK接口进行了限制,导致之前通过反射来设置TabLayout设置下划线宽度的方法失效了。好在Android提供了官方的属性tabIndicatorFullWidth来进行设置宽度。
即XML文件的TabLayout标签添加app:tabIndicatorFullWidth="false"

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="39dp"
        android:background="@color/w"
        app:tabIndicatorFullWidth="false"
        app:tabBackground="@android:color/transparent"
        app:tabGravity="fill"
        app:tabIndicatorColor="@color/a"
        app:tabIndicatorHeight="2dp"
        app:tabMode="fixed"
        app:tabPaddingEnd="0px"
        app:tabPaddingStart="0px"
        app:tabSelectedTextColor="@color/a"
        app:tabTextColor="@color/c" />

相关文章

网友评论

      本文标题:TabLayout设置下划线宽度(非反射)

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