Reputation: 1691
I'm using this great library you can see here but cant seem to set the bg color for the bottomBar.
The code I'm using to set up the bottomBar is this :
bottomBar = BottomBar.attach(view, savedInstanceState);
bottomBar.setMaxFixedTabs(2);
bottomBar.setItemsFromMenu(R.menu.menu_bottom_bar, new OnMenuTabClickListener() {
@Override
public void onMenuTabSelected(@IdRes int menuItemId) {
Log.i(TAG, "onMenuTabSelected: " + menuItemId );
}
@Override
public void onMenuTabReSelected(@IdRes int menuItemId) {
Log.i(TAG, "onMenuTab- RE - Selected: " + menuItemId );
}
});
bottomBar.mapColorForTab(0, R.color.colorAccentPink);
bottomBar.mapColorForTab(1, R.color.colorAccentPink);
bottomBar.mapColorForTab(2, R.color.colorAccentPink);
I have also tried to set the setBackground method but didnt have any luck.
All i' getting is white background.
Thank you
EDIT :
<?xml version="1.0" encoding="utf-8"?>
<item
android:id="@+id/bb_menu_comments"
android:icon="@drawable/ic_comments"
android:title="Comments" />
<item
android:id="@+id/bb_menu_poll"
android:icon="@drawable/ic_poll"
android:title="Polls" />
<item
android:id="@+id/bb_menu_share"
android:icon="@drawable/ic_share"
android:title="Share" />
Upvotes: 1
Views: 1290
Reputation: 101
mBottomBar.getBar().setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
Try this line. It works perfect for me.
Upvotes: 0
Reputation: 12002
You are passing a wrong parameter to the mapColorForTab
method. R.color.colorAccentPink
is just a resource id, but you need to extract color from it like this:
bottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorAccentPink));
Upvotes: 2