Search code examples
javaandroidxmlnavigationnavigation-drawer

Bottom Navigation Icon color change


I am using a BottomNavigation this when i try to change bottom navigation icon colors with black background its not change color.

 bottomNavigation.setAccentColor(Color.parseColor("#FFE4770A"));
 bottomNavigation.setInactiveColor(Color.WHITE);
 bottomNavigation.setBackgroundColor(Color.BLACK);

But when i tried it with background it changes icon color.

 bottomNavigation.setAccentColor(Color.parseColor("#FFE4770A"));
 bottomNavigation.setInactiveColor(Color.WHITE);

How do fix it? it changes icon color with color background.


Solution

  • According to the documentation of ahbottomnavigation repo, setBackgroundColor() will override the accent colors for icons.

    Replace setBackgroundColor() with setDefaultBackgroundColor() :

     bottomNavigation.setDefaultBackgroundColor(Color.BLACK);