1.首先 你要把版本至少升到28
implementation 'com.android.support:design:28.0.0-rc01'
然后 在其中加上
app:tabIndicatorFullWidth="false"
这个就跟文字同宽了....
<com.google.android.material.tabs.TabLayout
app:tabIndicatorHeight="9px"
app:tabBackground="@android:color/transparent"
app:tabIndicatorColor="@color/label_color"
app:tabSelectedTextColor="@color/label_color"
app:tabTextAppearance="@style/OrderTabLayoutTextAppearance"
app:tabTextColor="@color/home_gray"
app:tabIndicatorFullWidth="false"
app:tabGravity="fill"
app:tabMode="fixed"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
第二条路就是:
反射...
使用反射这个方法网上很多例子,自己