How to set inactive tab colour for BottomBar

孤街浪徒 提交于 2019-12-12 03:48:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!