如何为BottomBar设置不活动的选项卡颜色 [英] How to set inactive tab colour for BottomBar
问题描述
我正在尝试为BottomBar上的非活动选项卡设置颜色,但是找不到任何方法.我使用以下方法设置了酒吧的背景色:
mBottomBar.getBar().setBackgroundColor(getResources().getColor(R.color.colorPrimary));
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");
在所有四个标签上的
.mapColorForTab(1, "#ffffff"#);
等
on all the four tabs e.g. .mapColorForTab(1, "#ffffff"#);
etc.
推荐答案
您可以使用以下行来设置特定标签的背景色:
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.
这篇关于如何为BottomBar设置不活动的选项卡颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!