这里有一个很好的教程:
http://guides.codepath.com/android/google-play-style-tabs-using-tablayout
您可以使用带深色的textColor或使用tab的白色背景:
@dimen/tab_max_width
?attr/colorAccent
2dp
12dp
12dp
@android:color/white
@style/MyCustomTabTextAppearance
?android:textColorPrimary
14sp
#000000
true
然后将它用作TabLayout的样式:
android:id="@+id/tabs"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
或者其他定制.
更新:此外,无需添加样式,只需:
app:tabBackground="@android:color/white"
app:tabTextColor="@color/darkcolor"
即:
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:tabIndicatorColor="#ffffff"
app:tabIndicatorHeight="4dp"
app:tabBackground="@android:color/white"
app:tabTextColor="@color/darkcolor"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />