可以像下面这样实现
通过xml
<android.support.design.widget.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Light"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="4dp"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
并以编程方式
tabLayout.setTabMode(TabLayout.MODE_FIXED);
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句