android带消息红点的视图,超简洁的实现

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.Button;

public class RedButton extends Button {
    private Paint paint = new Paint();


    public RedButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        paint.setColor(Color.RED);
        canvas.drawCircle(getWidth() - 30, 30, 30, paint);
    }
}

你可能感兴趣的:(android,canvas,android,消息红点,提示视图)