Android自定义控件复写View的onDraw()方法,参数canvas是从哪里来的?
参数canvas是怎么得来的?@OverrideprotectedvoidonDraw(Canvascanvas){super.onDraw(canvas);intr=g...
参数canvas是怎么得来的?
@Override
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
int r=getWidth()/2;
int centerX=getLeft()+r;
int centerY=getTop()+r;
Paint paint=new Paint();
paint.setColor(Color.RED);
canvas.drawCircle(centerX,centerY,r,paint);
} 展开
@Override
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
int r=getWidth()/2;
int centerX=getLeft()+r;
int centerY=getTop()+r;
Paint paint=new Paint();
paint.setColor(Color.RED);
canvas.drawCircle(centerX,centerY,r,paint);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询