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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…