Search code examples
androidandroid-fragmentsandroid-tabs

tabs color changing


I was just wondering about tabs that change color when you are on the selected fragment For example: like facebook app tabs, when you are on home page the icon color changes to blue. Is this a tool or library used, or just i have to explicitly change all colors when fragment change ?


Solution

  • Try out bottom navigation view (https://developer.android.com/reference/android/support/design/widget/BottomNavigationView) by android and use a color selector like

    background_color.xml

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_checked="true" android:color="@color/blue" />
        <item android:color="@color/grey" />
    </selector>
    

    and use this as

    app:itemIconTint="@color/background_color.xml"
    

    in your bottom navigation view.