Background color change in BottomNavigationView

前端 未结 5 1268
轻奢々
轻奢々 2020-12-13 18:43

I have implemented BottomNavigationView which is available from the new support library 25.0.0. Here is my code for that



        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 19:10

    found an answer from this medium post

    1. We need to use android:state_checked instead of android:state_enabled
    2. within onNavigationItemSelected you need to use return true instead of return false.

    and to set background, we cannot use android:color in , we need to use android:drawable

    So here how it looks xml file when you are setting it for app:itemTextColor and app:itemIconTint

    
    
        
        
    
    

    and to set app:itemBackground selector

    
    
        
        
    
    

    Here banner_white and banner_green are pngs.

提交回复
热议问题