Search code examples
javaandroidandroid-tabsbottomnavigationview

How to set inactive tab colour for BottomBar


I am trying to set the colour for the inactive tabs on BottomBar but can't find any method for doing so. I have set the background colour for the bar using this: mBottomBar.getBar().setBackgroundColor(getResources().getColor(R.color.colorPrimary));

and would like to set the tabs to appear as white even when not in use, however don't seem to be able to do it: I am trying this method, but it doesn't work:

mBottomBar.mapColorForTab(0, "#ffffff");

on all the four tabs e.g. .mapColorForTab(1, "#ffffff"#); etc.


Solution

  • You can set the backgroundcolor of a specific tab by using the following line:

    bottomBar.getTabAtPosition(0).setBackgroundColor(backgroundColorInt);
    

    When you use this line multiple times for each tab, you can change the backgroundcolor of the whole tab.