Search code examples
androidbottombar

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


Solution

  • Try with this. It works for me

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