I have implemented BottomNavigationView
with badge count based on this example
https://stackoverflow.com/a/56340643/6699103
it works fine but I wanted to change the background color for badge Is there any way to do that?
Just use the method setBackgroundColor()
of the badge.
BadgeDrawable badge = bottomNavigationView.getOrCreateBadge(menuItemId);
badge.setNumber(..);
badge.setBackgroundColor(....);
If you want to change globally in your app the style you can define the badgeStyle
attr in your app theme:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
<item name="badgeStyle">@style/CustomBadge</item>
...
</style>
<style name="CustomBadge" parent="@style/Widget.MaterialComponents.Badge">
<item name="backgroundColor">@color/.....</item>
</style>
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