我尝试了几种解决方案,但没有任何效果。在某些设备上,标签栏无法填充父级的宽度。它在Samsung Tab 2等设备上运行良好,而在象素2等设备上则无法运行(就像附加的图像一样)。

android - 标签图标未填满全角-LMLPHP

<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"
        />


`

最佳答案

使用fixed tabMode代替scrollable

app:tabMode="fixed"

07-24 09:49
查看更多