material-components / material-components/material-components-android

[BadgeDrawable] Color selector not being respected for badge background

Open
#2,764 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Good First Issue Widget: Badge
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.