Display a badgeView on any view with RealTime Update.
Add This Line To your build.gradle (lastest v1.0.9):
dependencies {
implementation 'com.github.karim-eg:Smart-BadgeView:1.0.9'
}private BadgeView badgeView;import com.enceptcode.badgeview.BadgeFactory;
import com.enceptcode.badgeview.BadgeView;badgeView = BadgeFactory.createCircle(MainActivity.this);You Can Replace createCircle() property with: createDot(), createRectangle(), createOval(), createSquare(), createRoundRect()
private void updateBadge(final String count, final ImageView image) {
badgeView.setBadgeCount(count).setSpace(5,3).setTextSize(10).bind(image);
}- you can add or change any property to other available methods:
.setTextColor(Color.White)
.setWidthAndHeight(25,25)
.setBadgeBackground(Color.Red)
.setTextSize(10)
.setBadgeGravity(Gravity.Right|Gravity.Top)
.setShape(BadgeView.SHAPE_CIRCLE)
finally add this line at onResume or onCreate to call the void you had created before and display badge.
updateBadge("21", imageview3);void have two parameters first is the badge count, second is the view that badge will display on it.
badgeView.unbind();