<item
android:id="@+id/nav_gallery"
app:actionViewClass="android.widget.TextView"/>
This is the menu of bottom Navigation.
TextView gallery=(TextView)
MenuItemCompat.getActionView(navigationView.getMenu().
findItem(R.id.nav_gallery)); //getting menu item of bottom nav view
gallery.setText("99+");
But this code doesnot work for bottom navigation view.BottomNavigationView is shown without setting any notification counter.
The Latest Material dependency now supports natively add badge count, Need to just updated Material dependency in build.gradle
implementation 'com.google.android.material:material:1.1.0-alpha09'
and just add
val navBar = findViewById<BottomNavigationView>(R.id.bottom_navigation)
navBar.getOrCreateBadge(R.id.action_stamp).number = 2
and in style.xml just change "AppCompat" to "MaterialComponents"
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With