Artem  Shevchenko Artem Shevchenko - 4 months ago 36
Android Question

How to set backgorund 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

Answer

Try with this. It works for me

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