material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[BadgeDrawable] add margin for Badge

Open Chaoyang0201 opened this issue 7 years ago • 10 comments

I'm using badge with BottomNavigationView ,
but the badge position only change by gravity , so I can't control the position of badge

Is there any plan to add something like margin to control the position of badge?

Chaoyang0201 avatar Sep 26 '19 07:09 Chaoyang0201

Hi @Chaoyang0201 could you please explain how you'd like to position the badge and why gravity is not sufficient?

wcshi avatar Sep 26 '19 13:09 wcshi

Hi @wcshi

for example,

I want let a badge could cover the top right corner of the button icon like this image

but using gravity can't let badge over the icon .

Chaoyang0201 avatar Sep 26 '19 15:09 Chaoyang0201

I checked with our designers and they agree with supporting your use case, will add this to our next sprint.

wcshi avatar Oct 11 '19 19:10 wcshi

Glad to hear this : )

Chaoyang0201 avatar Oct 12 '19 02:10 Chaoyang0201

The associated PR has been pulled in internally, waiting for the changes to be synced out.

wcshi avatar Oct 21 '19 14:10 wcshi

I saw the commit. How to use it to reposition the badge?

aznj avatar Feb 19 '20 04:02 aznj

I saw the commit. How to use it to reposition the badge?

if you are using BottomNavigationView, you can reposition the badge like this

BadgeDrawable badge = bottomNavigationView.getOrCreateBadge(YOUR_MENU_ITEM_ID);
badge.setHorizontalOffset(px);
badge.setVerticalOffset(px);

Chaoyang0201 avatar Feb 19 '20 04:02 Chaoyang0201

@dsn5ft , Did you add this feature? @Chaoyang0201 , How can i use setHorizontalOffset(px)?

miladsalimiiii avatar Jun 06 '20 12:06 miladsalimiiii

I saw the commit. How to use it to reposition the badge?

if you are using BottomNavigationView, you can reposition the badge like this

BadgeDrawable badge = bottomNavigationView.getOrCreateBadge(YOUR_MENU_ITEM_ID);
badge.setHorizontalOffset(px);
badge.setVerticalOffset(px);

@miladsalimiiii have a try

Chaoyang0201 avatar Jun 08 '20 01:06 Chaoyang0201

I saw the commit. How to use it to reposition the badge?

if you are using BottomNavigationView, you can reposition the badge like this

BadgeDrawable badge = bottomNavigationView.getOrCreateBadge(YOUR_MENU_ITEM_ID);
badge.setHorizontalOffset(px);
badge.setVerticalOffset(px);

@miladsalimiiii have a try

Thank you this work on alpha and beta version.

miladsalimiiii avatar Jun 12 '20 07:06 miladsalimiiii