class CircleView extends View { private Paint paint; private int radius = 0; private int max = 2000; private float centerX; private float centerY; public CircleView(Context context) { super(context); initView(); } public CircleView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); initView(); } public CircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initView(); } private void initView() { paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(ColorUtil.getColor(R.color.colorAccent)); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (radius < max) { radius += 20; canvas.drawCircle(centerX, centerY, radius, paint); postInvalidateDelayed(10); } else { canvas.drawCircle(centerX, centerY, max, paint); } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); centerX = w / 2; centerY = h / 2; } }