material-components / material-components/material-components-android
[BadgeDrawable] Color selector not being respected for badge background
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**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:
```
<item name="backgroundColor">@color/badge_bg</item>
<item name="badgeTextColor">@color/badge_text</item>
```
And `badge_bg` looks like this:
```
```
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with BadgeDrawable, the StudioBadge style, and the badge_bg selector shown in the report on the stated Android and Material Library versions. Trace how badgeStyle backgroundColor is applied and verify that the badge changes from color_two to color_one when the tab is selected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100