当用户触摸屏幕并在屏幕上移动手指时,我想在屏幕上画一个圆圈。当在屏幕上移动手指时,圆圈的大小应该改变。当前,当我绘制圆时,多个圆正在绘制。
when (action) {
MotionEvent.ACTION_DOWN -> {
mStartX = mx
mStartY = my
}
MotionEvent.ACTION_MOVE -> {
}
MotionEvent.ACTION_UP -> {
mCanvas!!.drawCircle(
mStartX,
mStartY,
calculateRadius(mStartX, mStartY, mx, my),
mPaint
)
}
}
invalidate()}
in method onDraw()
if (mCurrentShape == RECTANGLE) {
drawRectangle(canvas, mPaint)
} else if(mCurrentShape == CIRCLE){
mCanvas!!.drawCircle(
mStartX,
mStartY,
calculateRadius(mStartX, mStartY, mx, my),
mPaint
)
}
问题图片添加在这里
1条答案
按热度按时间cgh8pdjw1#
经过数小时的研究,我得到了这个博客:http://gmariotti.blogspot.com/2014/01/drawing-shapes-with-fingers.html