protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//绘制时钟的外圈,
circlePaint.setColor(circleColor01);
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2,
this.getWidth() / 2, circlePaint);
circlePaint.setColor(circleColor02);
canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2,
this.getWidth() / 2 - circleWidth, circlePaint);
//绘制时钟的表盘
canvas.save();
for (int i=0;i<12;i++) {
canvas.drawLine(this.getWidth()/2,20*density,
this.getWidth()/2,circleWidth + 1*density,linePaint);
canvas.rotate(30,this.getWidth()/2,this.getHeight()/2);
}
canvas.restore();
//刻度值数字
//绘制小时,分钟和秒数针
canvas.save();
canvas.rotate(hour * 30 + minute / 2, this.getWidth() / 2, this.getHeight() / 2);
timerPaint.setStrokeWidth(5.0f * density);
canvas.drawLine(this.getWidth() / 2, this.getHeight() / 2, this.getWidth() / 2,
circleWidth + (this.getHeight() / 5) * density, timerPaint);
canvas.restore();
canvas.save();
canvas.rotate(minute * 6, this.getWidth() / 2, this.getHeight() / 2);
timerPaint.setStrokeWidth(4.0f * density);
canvas.drawLine(this.getWidth() / 2, this.getHeight() / 2,
this.getWidth() / 2, circleWidth + (this.getHeight() / 7) * density, timerPaint);
canvas.restore();
canvas.save();
canvas.rotate(second * 6,this.getWidth()/2,this.getHeight()/2);
timerPaint.setStrokeWidth(3.0f*density);
canvas.drawLine(this.getWidth()/2,this.getHeight()/2,
this.getWidth()/2,circleWidth+(this.getHeight()/9)*density,timerPaint);
canvas.restore();
}
<img src="https://img-blog.csdn.net/20160315232136063?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />