badgeview

时间:2022-04-21 07:03:01

https://github.com/AlexLiuSheng/BadgeView

include:

compile 'com.allenliu.badgeview:library:1.1.1'(newest)

bind like this:

 BadgeFactory.create(this)
.setTextColor(Color.White)
.setWidthAndHeight(25,25)
.setBadgeBackground(Color.Red)
.setTextSize(10)
.setBadgeGravity(Gravity.Right|Gravity.Top)
.setBadgeCount(20)
.setShape(BadgeView.SHAPE_CIRCLE)
.setSpace(10,10)
.bind(view);

if u want to set space dont use setMargin(),use setSpace instead.

There are some other constructer methods and you can be easy to create your own shape :

BadgeFactory.createDot(this).setBadgeCount(20).bind(imageView);
BadgeFactory.createCircle(this).setBadgeCount(20).bind(imageView);
BadgeFactory.createRectangle(this).setBadgeCount(20).bind(imageView);
BadgeFactory.createOval(this).setBadgeCount(20).bind(imageView);
BadgeFactory.createSquare(this).setBadgeCount(20).bind(imageView);
BadgeFactory.createRoundRect(this).setBadgeCount(20).bind(imageView);

unbind view just use unbind method.

 badgeView.unbind();