Reputation: 329
I want to add a badge in my button, how can i do that ?
Button :
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/badge_circle"
android:gravity="center"
android:padding="12dip"
android:text="Button"
android:textColor="#ffffff"/>
Upvotes: 9
Views: 16255
Reputation: 482
You can use this
BadgeDrawable badgeDrawable = BadgeDrawable.create(getContext());
badgeDrawable.setNumber(3);
badgeDrawable.setVisible(true);
BadgeUtils.attachBadgeDrawable(badgeDrawable, tragetView);
check for more https://material.io/develop/android/components/badging
Upvotes: 6
Reputation: 1311
Use this library
Sample example provided by library
View target = findViewById(R.id.target_view);
BadgeView badge = new BadgeView(this, target);
badge.setText("1");
badge.show();
Also check this Question
Upvotes: 2