How do I set the background color?
See original GitHub issueI’d like to have my BottomBar use a custom color as the background for tabs, with non-selected tabs using another custom color for text/icon (essentially a darker version of said custom color), and the selected tab using white for text/color. So the same background color at all times, across all tabs. Sounds simple, but how can I accomplish this?
I have so far found useDarkMode which causes the bottom bar to be dark grey with white icons. If not using dark mode, the bottom bar is instead light grey with dark icons.
If setting setMaxFixedTabs(n-1), and NOT mapping any colors to tabs, my bottom bar gets the primaryColor from the theme as the background, with tabs in white/grey. This seems fairly undocumented, and why is there no way of having the BottomBar use R.attr.primaryColor without fixed tabs mode - why just light or dark…?
If I do use mapColorForTab, I can have my custom color as the background, but this only works if setMaxFixedTabs is used, which I don’t particularly like due to the offset/resize effects (if having three tabs, I think it looks strange when the middle tab is not center-fixed). Also, I am not sure from where the unselected tabs get their color (it looks like white with 0.5 alpha or something).
Is there some combination of attributes I can use to achieve what I need? Why is there no simple setTabBackground and setInactiveTabColor?
I also noted that if using View.setBackgroundColor on the BottomBar, the background of my activity is instead changed; I guess this is because BottomBar is essentially a full-screen FrameLayout?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)

Top Related StackOverflow Question
I found this ugly workaround for setting the background color:
mBottomBar.findViewById(R.id.bb_bottom_bar_background_view).setBackgroundColor(myColor);But regarding unselected tab colors for text/icon, it seems
mInActiveColoris hard-coded tomInActiveColor = ContextCompat.getColor(getContext(), R.color.bb_inActiveBottomBarItemColor);I suggest adding
setTabBackgroundColor(int)andsetInactiveTabColor(int), what do you think?Shouldn’t you be using getColor() as opposed to getDrawable()?
I’m thinking the system fails to find a drawable with the id of your color, and it ends up as a no-op?
Den 3 nov 2016 6:38 em skrev Etienne Théodore notifications@github.com:
Ok guys, i can’t setBackground programmatically. I don’t know why.
This works : <com.roughike.bottombar.BottomBar android:id=“@+id/bottomBar” android:layout_width=“match_parent” android:layout_height=“60dp” android:background=“@color/colorAccent” android:layout_alignParentBottom=“true” app:bb_tabXmlResource=“@xml/bottombar_tabs” />
But this not : BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar); bottomBar.setBackground(ContextCompat.getDrawable(this,R.color.colorAccent));
Can you help me for this ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/roughike/BottomBar/issues/205#issuecomment-258217376, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJKcQhLoRfWGr3WagEd7e_gRIadi5o58ks5q6hwCgaJpZM4IXJsZ.