实现目标:
消息数量的显示,如果消息数量是“99+”的时候也必须是圆形
效果图
遇到的问题:
消息数量是一位数和两位数时候都可以实现是圆形的,但是一旦是“99+”就变形了
(苦逼啊,真的是在网上找了好多资料啊…),终于找到解决方法了,直接上代码
public class CircleTextView extends AppCompatTextView {
private Paint circlePaint;
private Paint backPaint;
private Paint textPaint;
private int storkColor = Color.WHITE;
private int circleBackColor = Color.WHITE;
private float storkWidth;
public CircleTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setGravity(Gravity.CENTER);
circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setStyle(Paint.Style.STRO