本以为设置tabmode为scrollable就可以了,每个tab就会按照自己自定义的view展示。然并卵。
解决方法:
<com.google.android.material.tabs.TabLayout android:id="@+id/tabLayout" style="@style/Widget.MaterialComponents.TabLayout" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" android:layout_marginStart="16dp" android:layout_marginEnd="16dp" app:layout_constraintTop_toBottomOf="@id/appBarLayout" app:tabGravity="fill" app:tabIndicatorHeight="0dp" app:tabMaxWidth="0dp" app:tabMode="scrollable" app:tabPaddingEnd="0dp" app:tabPaddingStart="0dp" app:tabTextColor="?attr/colorPrimaryDark" />
最主要一定要设置maxwidth为0