BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
BadgeView.Builder.newBuilder()
.setTargetView(menuView.getChildAt(0))
.setBadgeCount(10)
.setMargin(new Integer[]{0, 8, 24, 0})
.build(this);
BadgeView.Builder.newBuilder()
.setTargetView(menuView.getChildAt(1))
.setBadgeCount(2)
.setMargin(new Integer[]{0, 8, 24, 0})
.build(this);
BadgeView.Builder.newBuilder()
.setTargetView(menuView.getChildAt(2))
.setBadgeCount(8)
.setMargin(new Integer[]{0, 8, 24, 0})
.build(this);
//获取整个的NavigationView
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
//这里就是获取所添加的每一个Tab(或者叫menu),
View tab = menuView.getChildAt(3);
BottomNavigationItemView itemView = (BottomNavigationItemView) tab;
//加载我们的角标View,新创建的一个布局
View badge = LayoutInflater.from(this).inflate(R.layout.menu_badge, menuView, false);
//添加到Tab上
itemView.addView(badge)
TextView count = (TextView) badge.findViewById(R.id.tv_msg_count);
count.setText(String.valueOf(1));
//如果没有消息,不需要显示的时候那只需要将它隐藏即可
count.setVisibility(View.GONE)
————————————————