I just want to add badge for a menuItem
of BottomNavigationView
in my app. I'm using BottomNavigationView
of Material Components library(version 1.1.0-alpha08) since its the latest version released just 7 days ago from now I didn't found any tutorial for the same, Now because there are changes made in this version of BottomNavigationView
's showBadge method we cannot use that method.
I've tried calling getBadge
and getOrCreateBadge
method over instance of BottomNavigationView
.
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
if (bottomNavigationView.getBadge(3) == null) {
audioPlayingCountBadge = bottomNavigationView.getOrCreateBadge(3);
audioPlayingCountBadge.setBackgroundColor(
getResources().getColor(R.color.colorPrimaryDark)
);
} else {
audioPlayingCountBadge = bottomNavigationView.getBadge(3);
}
audioPlayingCountBadge.setVisible(true);
If anyone can provide solution for this problem in detail that would be very grateful to me.