问题
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.
回答1:
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.
回答2:
Using the darkMode
function solved this. Simply set in MainActivity.java
like so:
mBottomBar.useDarkTheme();
来源:https://stackoverflow.com/questions/38349897/how-to-set-inactive-tab-colour-for-bottombar