material-components/material-components-android
在 GitHub 查看[BadgeDrawable] Color selector not being respected for badge background
Open
#2,764 建立於 2022年6月17日
Good First IssueWidget: Badgefeature request
描述
Description: Adding a color selector to the badgeStyle -> backgroundColor doesn't see to work as expected. Color doesn't change when Tab is selected.
Expected behavior: Badge color would respect color selector
Source code:
I've tried every single property I could find, and it didn't make a difference. Here's a sample example:
<style name="StudioBadge" parent="Widget.MaterialComponents.Badge">
<item name="backgroundColor">@color/badge_bg</item>
<item name="badgeTextColor">@color/badge_text</item>
</style>
And badge_bg looks like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/color_one"/>
<item android:color="@color/color_two"/>
</selector>
In this example, only color_two gets applied to the badge, even though following the same process the tab text changes accordingly.
Android API version: 12
Material Library version: 1.4.0
Device: Samsung S20 & Pixel 1