ittianyu / BottomNavigationViewEx

An android lib for enhancing BottomNavigationView. 一个增强BottomNavigationView的安卓库。
MIT License
3.47k stars 558 forks source link

Icon color not showing with compile version 29 #195

Open Studiosnlabs opened 3 years ago

Studiosnlabs commented 3 years ago

Hi i am using your library in androidx and The color of the icons are not showing on the menu. Can you please help? below is my code

`  <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/bottomNavViewBar"
            android:background="@drawable/white_gray_border_top"
            app:menu="@menu/bottom_navigation_menu">

        </com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>`
FlameAlchemist16 commented 3 years ago

I hope this will help you :)

If you want to display a single color when the icon is checked or not then consider adding the following code above :

`app:itemIconTint="@color/that_color"`

Else if you want to change between two colors depending on whether the icon is checked or not then you need to make a selector file in your drawable folder with a name say "bottom_nav_color_selector":

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:color ="@color/black"/> <item android:state_checked="false" android:color ="@color/grey"/> </selector>

and add this line of code in your code above

app:itemIconTint="@drawable/bottom_nav_color_selector"