BadgeUtils

open class BadgeUtils

Utility class for BadgeDrawable.

Warning: This class is experimental and the APIs are subject to change.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open fun attachBadgeDrawable(@NonNull badgeDrawable: BadgeDrawable, @NonNull anchor: View)

open fun attachBadgeDrawable(@NonNull badgeDrawable: BadgeDrawable, @NonNull anchor: View, @Nullable customBadgeParent: FrameLayout)
Attaches a BadgeDrawable to its associated anchor and update the BadgeDrawable's coordinates based on the anchor.
open fun attachBadgeDrawable(@NonNull badgeDrawable: BadgeDrawable, @NonNull toolbar: Toolbar, @IdRes menuItemId: Int)
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.
open fun attachBadgeDrawable(@NonNull badgeDrawable: BadgeDrawable, @NonNull toolbar: Toolbar, @IdRes menuItemId: Int, @Nullable customBadgeParent: FrameLayout)
Attaches a BadgeDrawable to its associated action menu item on a toolbar, update the BadgeDrawable's coordinates based on this anchor and adjust the BadgeDrawable's offset so it is not clipped off by the toolbar.
Link copied to clipboard
Given a map of int keys to SavedStates, creates a parcelable map of int keys to BadgeDrawbles.
Link copied to clipboard
Given a map of int keys to BadgeDrawable BadgeDrawables, creates a parcelable map of unique int keys to BadgeDrawable.SavedState SavedStates.
Link copied to clipboard
open fun detachBadgeDrawable(@Nullable badgeDrawable: BadgeDrawable, @NonNull anchor: View)
Detaches a BadgeDrawable from its associated anchor.
open fun detachBadgeDrawable(@Nullable badgeDrawable: BadgeDrawable, @NonNull toolbar: Toolbar, @IdRes menuItemId: Int)
Detaches a BadgeDrawable from its associated action menu item on a toolbar, For API 18+, the BadgeDrawable will be removed from its anchor's ViewOverlay.
Link copied to clipboard
open fun setBadgeDrawableBounds(@NonNull badgeDrawable: BadgeDrawable, @NonNull anchor: View, @Nullable compatBadgeParent: FrameLayout)
Sets the bounds of a BadgeDrawable to match the bounds of its anchor (for API 18+) or its anchor's FrameLayout ancestor (pre-API 18).
Link copied to clipboard
open fun updateBadgeBounds(@NonNull rect: Rect, centerX: Float, centerY: Float, halfWidth: Float, halfHeight: Float)
Updates a badge's bounds using its center coordinate, halfWidth and halfHeight.