最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to Change TabLayout Color In Android xml - Stack Overflow

programmeradmin1浏览0评论

I'm looking forward to change the color of this part of TabLayout When user swipes but there's not more items to swipe to.

color

This is My xml:

<com.google.android.material.tabs.TabLayout
        android:id="@+id/main_tab_layout"
        style="@style/TabLayout"
        android:layout_width="327dp"
        android:layout_height="60dp"
        android:background="@drawable/tab_layout_bg"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar" />

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/tab_layout_viewPager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginStart="23dp"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="23dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/main_tab_layout" />

And this is style of my TabLayout:

<style name="TabTextStyle" parent="@android:style/TextAppearance.Widget.TabWidget">
        <item name="android:textSize">16sp</item>
        <item name="fontFamily">@font/graphik_medium</item>
        <item name="android:textColor">?attr/colorControlNormal</item>
    </style>

    <style name="TabLayout" parent="Theme.Dooit">
        <item name="tabTextAppearance">@style/TabTextStyle</item>
        <item name="tabSelectedTextColor">@color/white</item>
        <item name="tabMode">fixed</item>
        <item name="tabGravity">fill</item>
        <item name="tabIndicator">@drawable/tab_layout_custom_indicator</item>
        <item name="tabIndicatorColor">@color/black</item>
        <item name="tabIndicatorGravity">center</item>
        <item name="tabIndicatorFullWidth">true</item>
        <item name="tabRippleColor">@android:color/transparent</item>
    </style>
发布评论

评论列表(0)

  1. 暂无评论