Artem
Artem

Reputation: 4639

How to set background color for BottomBar?

I using this library for using BottomBar in my app and I can't set background color for this BottomBar.

My code:

 mBottomBar = BottomBar.attach(parent.findViewById(R.id.content), savedInstanceState);
    mBottomBar.setItemsFromMenu(R.menu.bottombar_menu, new OnMenuTabClickListener() {
        @Override
        public void onMenuTabSelected(@IdRes int menuItemId) {

        }

        @Override
        public void onMenuTabReSelected(@IdRes int menuItemId) {

        }
    });

    mBottomBar.mapColorForTab(0, ContextCompat.getColor(getActivity(), R.color.colorAccent));
    mBottomBar.mapColorForTab(1, ContextCompat.getColor(getActivity(), R.color.colorAccent));

My BottomBar background color is white - I want set BootomBar like: enter image description here

UPD 1 I tried this code:

mBottomBar.setBackgroundColor(getResources().getColor(R.color.colorAccent));

But this change background on my content (Look to Content for nearby in screenshot), doesn't in BottomBar

Upvotes: 2

Views: 674

Answers (2)

476rick
476rick

Reputation: 2805

The accepted answer didn't work for me, I tried something else. When you change the background for each you have it does work. I added this line for every tab I have:

bottomBar.getTabAtPosition(0).setBackgroundColor(backgroundColorInt);

Upvotes: 1

Masum
Masum

Reputation: 4969

Try with this. It works for me

mBottomBar.getBar().setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));

Upvotes: 3

Related Questions