Skip to content

Commit

Permalink
[Badge] Add note in attachBadgeDrawable method docs about menu item v…
Browse files Browse the repository at this point in the history
…iews being re-used when there is a structural change in the menu. Since badges are attached to the views, this may change the menu item that the badge is intended for

PiperOrigin-RevId: 566995151
  • Loading branch information
imhappi authored and dsn5ft committed Sep 21, 2023
1 parent 0a8fc61 commit 5e6ea58
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/java/com/google/android/material/badge/BadgeUtils.java
Expand Up @@ -105,6 +105,9 @@ public static void attachBadgeDrawable(
* A convenience method to attach a BadgeDrawable to the specified menu item on a toolbar, update
* the BadgeDrawable's coordinates based on its anchor and adjust the BadgeDrawable's offset so it
* is not clipped off by the toolbar.
*
* <p>Menu item views are reused by the menu, so any structural changes to the menu may require
* detaching the BadgeDrawable and re-attaching it to the correct item.
*/
public static void attachBadgeDrawable(
@NonNull BadgeDrawable badgeDrawable, @NonNull Toolbar toolbar, @IdRes int menuItemId) {
Expand All @@ -117,6 +120,9 @@ public static void attachBadgeDrawable(
* not clipped off by the toolbar. For API 18+, the BadgeDrawable will be added as a view overlay.
* For pre-API 18, the BadgeDrawable will be set as the foreground of a FrameLayout that is an
* ancestor of the anchor.
*
* <p>Menu item views are reused by the menu, so any structural changes to the menu may require
* detaching the BadgeDrawable and re-attaching it to the correct item.
*/
public static void attachBadgeDrawable(
@NonNull final BadgeDrawable badgeDrawable,
Expand Down

0 comments on commit 5e6ea58

Please sign in to comment.