I am using
to set BottomNavigationView in my android app. My question is
First you need to add app:actionLayout in menu file's item where you want to show badge of your BottomNavigationView like this
where unread_message_layout is the layout which has badge something like below
Here is the XML of that layout
and in your activity where BottomNavigationView is available, add this to show badges
var mbottomNavigationMenuView = binding.bottomNavigationView.getChildAt(0) as BottomNavigationMenuView
var chatBadge = LayoutInflater.from(this).inflate(R.layout.unread_message_layout,
mbottomNavigationMenuView, false)
var itemView = mbottomNavigationMenuView.getChildAt(2) as BottomNavigationItemView
val tvUnreadChats = chatBadge.findViewById(R.id.tvUnreadChats) as TextView
tvUnreadChats.text = "1"//String that you want to show in badge
itemView.addView(chatBadge)
Here getChildAt(2) is third item in my BottomNavigationView