material-components/material-components-android
Vedi su GitHub[BadgeDrawable] Color selector not being respected for badge background
Open
#2764 aperta il 17 giu 2022
Good First IssueWidget: Badgefeature request
Metriche repository
- Star
- (15.910 star)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
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