I am using the Bottomnavigationview
for tab-bar in my application, for it, i am using the following code.Please check it once.
Layout :-
I have done the above task as the following approach, please have a look on the solution
Layout
/// YOUR MENU ITEMS FOR THE BOTTOM NAVIGATION
Your badge count layout be like below
And than after your badge drawable be like below
And at the last, you need we need to inflate our badge layout into our MainActivity.java , where we use the BottomNavigationView, please check the following code for it.
BottomNavigationMenuView mbottomNavigationMenuView =
(BottomNavigationMenuView) mBinding.bottomNavigation.getChildAt(0);
View view = mbottomNavigationMenuView.getChildAt(4);
BottomNavigationItemView itemView = (BottomNavigationItemView) view;
View cart_badge = LayoutInflater.from(this)
.inflate(R.layout.profile_view,
mbottomNavigationMenuView, false);
//// AND THAN SET THE COUNTER BADGE, AS FOLLOW
((TextView) cart_badge.findViewById(R.id.notificationsBadge)).setText("5");
itemView.addView(cart_badge);