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

[BadgeDrawable] Please remove anchorView requirement

Open
#1,967 0 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: Badge
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Recently support for showing a badge on toolbar action items was introduced but it's error prone. Please see my question at Stack Overflow: https://stackoverflow.com/questions/65597372/livedata-update-of-badgedrawable-in-toolbar-menuitem.

**Describe the solution you'd like**
BadgeDrawable relies on being attached to an anchor view. I would like to use it just as a plain Drawable. I don't have direct access to the views that deal with the BadgeDrawable and I don't undersand why that would even be necessary.

Please make `updateCenterAndBounds()` and related methods fall back to the drawable bounds if no anchor view is available to support plain usage in an `ImageView` or `LayerDrawable`.

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 locating BadgeDrawable and its updateCenterAndBounds() and related methods. Read how they use the anchor view, then inspect the plain ImageView and LayerDrawable usage described in the issue. Done means BadgeDrawable can operate without an anchor view while retaining its existing anchored behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.