Omar Walid
Omar Walid

Reputation: 57

Bottom navigation view icons colors does not appear correctly

I am having a problem with this BottomNavigationView library https://github.com/ittianyu/BottomNavigationViewEx

The colours I stated in this xml file don't appear correctly

color_state.xml

<?xml version="1.0" encoding="utf-8"?>

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:color="@android:color/black" android:state_checked="true" android:alpha="1"/>
        <item android:color="#bdbdbd" android:state_checked="false" />
    </selector> 

As you can see, I have set the state_checked = true color to black but instead it appears like this.

The same happens to state_checked = false, Any body know how can I solve this

Here is the BottomNavigation code:

<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:menu="@menu/navigation_view_menu"
        app:itemIconTint="@drawable/color_state"
        android:id="@+id/bottomnav"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:itemBackground="@android:color/transparent"
        app:itemTextColor="@drawable/state"
        android:background="@android:color/white"

        >



    </com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx> 

Upvotes: 4

Views: 1300

Answers (2)

lidkxx
lidkxx

Reputation: 2841

For me it was a really dumb thing - after hours of debugging, learning about differences between supplying @color and @drawable and differences between various states of the Views, it turned out that I had both layout and layout-v21 folders in my res directory and I was only editing the former.

Upvotes: 1

huangsu
huangsu

Reputation: 66

itemIconTint should be color resource not drawable, app:itemIconTint="@drawable/color_state" should change to app:itemIconTint="@color/color_state"

Upvotes: 2

Related Questions