如是support 包下的TabLayout 则设置:
<style name="TabLayoutStyle" parent="Widget.Design.TabLayout">
<item name="tabMaxWidth">@dimen/tab_max_width</item>
<item name="tabIndicatorColor">@color/black</item>
<item name="tabIndicatorHeight">2dp</item>
<item name="tabPaddingStart">8dp</item>
<item name="tabPaddingEnd">8dp</item>
<item name="tabBackground">?attr/selectableItemBackground</item>
<item name="tabTextAppearance">@style/TabTextAppearance</item>
<item name="tabSelectedTextColor">@android:color/white</item>
</style>
<style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/white</item>
<item name="textAllCaps">false</item>
</style>
<android.support.design.widget.TabLayout
style="@style/TabLayoutStyle"
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
如是com.google.android.material.tabs.TabLayout 包下的TabLayout 则设置:
<style name="customTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">@style/TabTextAppearance</item>
</style>
<style name="TabTextAppearance" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textAllCaps">false</item>
</style>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
style="@style/customTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
或:
<style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
</style>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
app:tabTextAppearance="@style/TabTextAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
网友评论