Skip to content

Latest commit

 

History

History
87 lines (59 loc) · 2.21 KB

README.md

File metadata and controls

87 lines (59 loc) · 2.21 KB

RealTime BadgeView

Display a badgeView on any view with RealTime Update.

StandWithPalestine

StandWithPalestine

Screenshot:

Step.1 Library implementation:

Add This Line To your build.gradle (lastest v1.0.9):

dependencies {
    implementation 'com.github.karim-eg:Smart-BadgeView:1.0.9'
}

Step.2 Create Private Variable:

private BadgeView badgeView;

if you're using ide that didn't support auto import add these lines:

import com.enceptcode.badgeview.BadgeFactory;
import com.enceptcode.badgeview.BadgeView;

Step.3 Add This Line at onCreate:

badgeView = BadgeFactory.createCircle(MainActivity.this);

You Can Replace createCircle() property with: createDot(), createRectangle(), createOval(), createSquare(), createRoundRect()


Step.4 Add This Void:

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)


Final Step:

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.


to unbind view just use unbind method:

badgeView.unbind();

License

Apache License