要设置Android SlidingTabLayout的样式,可以通过以下步骤进行:
<style name="CustomSlidingTabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/indicator_color</item>
<item name="tabTextAppearance">@style/CustomTabTextAppearance</item>
</style>
<style name="CustomTabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textColor">@color/text_color</item>
</style>
<com.google.android.material.tabs.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CustomSlidingTabLayout"/>
SlidingTabLayout slidingTabLayout = findViewById(R.id.sliding_tabs);
for (int i = 0; i < slidingTabLayout.getTabCount(); i++) {
TabLayout.Tab tab = slidingTabLayout.getTabAt(i);
if (tab != null) {
tab.setCustomView(R.layout.custom_tab_view);
}
}
通过以上步骤,可以很容易地设置Android SlidingTabLayout的样式。您可以根据自己的需求,定义不同的样式,以满足设计要求。