我尝试了几种解决方案,但没有任何效果。在某些设备上,标签栏无法填充父级的宽度。它在Samsung Tab 2等设备上运行良好,而在象素2等设备上则无法运行(就像附加的图像一样)。
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
app:layout_constraintBottom_toBottomOf="parent"
app:tabIndicatorColor="@color/colorBackground"
app:tabMode="scrollable"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabSelectedTextColor="@color/colorPrimary"
/>
`
还要检查doc:在
支持设计库:中重力尽可能多地填充
生效。TabLayout
。与MODE_FIXED
一起使用时,此选项仅生效使用Material Components Library:重力尽可能多地填充
TabLayout
。在小于MODE_FIXED
宽的非横向屏幕上与600dp
一起使用时,此选项仅生效
效果。