question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I set the background color?

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
henhalcommented, May 4, 2016

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 mInActiveColor is hard-coded to mInActiveColor = ContextCompat.getColor(getContext(), R.color.bb_inActiveBottomBarItemColor);

I suggest adding setTabBackgroundColor(int) and setInactiveTabColor(int), what do you think?

0reactions
henhalcommented, Nov 3, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set background color in HTML? - Tutorialspoint
To set the background color in HTML, use the style attribute, with the CSS property background-color inside the body tag of the HTML...
Read more >
CSS background-color property - W3Schools
The background-color property sets the background color of an element. The background of an element is the total size of the element, including...
Read more >
How to Add & Change Background Color in HTML
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place...
Read more >
The Quickest Way To Change Background To Any Color Online
Choose A Background Manipulation Tool · Select Your Images To Edit · Upload & Mark Your Images · Swap Out Background Color ·...
Read more >
How To Change Background Color in Photoshop (Fast & Easy!)
In this tutorial, you will learn how to how to change the background color in photoshop! We will use a simple yet powerful...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found