@Override publicvoidonMenuTabReSelected(@IdResint menuItemId){ if(menuItemId == R.id.nav_home){ // The user reselected item number one, scroll your content to top.
} } });
// Setting colors for different tabs when there's more than three of them. // You can set colors for tabs in three different ways as shown below. mBottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(1, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(2, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(3, ContextCompat.getColor(this, R.color.colorPrimaryDark)); mBottomBar.mapColorForTab(4, ContextCompat.getColor(this, R.color.colorPrimaryDark));
// Set the color for the active tab. Ignored on mobile when there are more than three tabs. // mBottomBar.setActiveTabColor("#009688");
// mBottomBar.selectTabAtPosition(1, true);
setNotificationBadge();
}
privatevoidsetNotificationBadge(){
// Make a Badge for the first tab, with red background color and a value of "13". BottomBarBadge unreadMessages = mBottomBar.makeBadgeForTabAt(4,"#FF0000",10);
// Control the badge's visibility unreadMessages.show(); // unreadMessages.hide();
// Change the displayed count for this badge. unreadMessages.setCount(4);
// Change the show / hide animation duration. unreadMessages.setAnimationDuration(200);
// If you want the badge be shown always after unselecting the tab that contains it. unreadMessages.setAutoShowAfterUnSelection(false); }
// Necessary to restore the BottomBar's state, otherwise we would // lose the current tab on orientation change. mBottomBar.onSaveInstanceState(outState); }
No comments:
Post a Comment