Search code examples
androidkotlinselectordrawablebottomnavigationview

BottomNavigatioView ColorStateList not work on api <=26


I have integrated the bottomNavigationView into my app. I have configured some ColorStateList to change the background color. This selector is ignored in api <= 26

This is my Background selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#B59339" android:drawable="@color/gold" android:state_checked="true" />
    <item android:color="#112620" android:drawable="@color/app_dark_color" android:state_checked="false" />
</selector>

And this is my bottomNavigationView

app:itemIconTint="@color/bottom_nav_tint"
app:itemTextColor="@color/bottom_nav_tint"

I've also tried using drawables, but it doesn't change anything

app:itemIconTint="@drawable/bottom_nav_tint"
app:itemTextColor="@drawable/bottom_nav_tint"

Solution

  • I've solved. I moved the colorFilterList file into drawable and called it like this:

    app:itemBackground="@drawable/bottom_nav_background"
    app:itemIconTint="@drawable/bottom_nav_tint"
    app:itemTextColor="@drawable/bottom_nav_tint"