Search code examples
androidandroid-fragmentscolorsbottomnavigationview

How to change bottom navigation icon color if I change Fragment programmatically


I am using bottom navigation to change fragments. For whatever reason, I need to change Fragment if the user taps a particular button. This method working fine, except a little aesthetic problem. If I change fragment programmatically, the bottom navigation icon color won't change.

For handling color change, I am using selector XML right now, but I am ready to use other solutions, to handle this little problem.


Solution

  • please follow this code, it may help you bottomNavigationView.setSelectedItemId(R.id.navigation_home);