Zer*_*ool 8 android material-design bottomnavigationview material-components material-components-android
我已经BottomNavigationView根据这个例子实现了徽章计数
/sf/answers/3943845041/
它工作正常,但我想更改徽章的背景颜色有什么办法吗?
Gab*_*tti 20
就用setBackgroundColor()徽章的方法吧。
BadgeDrawable badge = bottomNavigationView.getOrCreateBadge(menuItemId);
badge.setNumber(..);
badge.setBackgroundColor(....);
Run Code Online (Sandbox Code Playgroud)
如果您想在您的应用程序中全局更改样式,您可以badgeStyle在应用程序主题中定义attr:
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2287 次 |
| 最近记录: |