Java Android:使用onDraw在用户点击的地方画一个圆圈

Java Android:使用onDraw在用户点击的地方画一个圆圈,java,android,imageview,gesture,ondraw,Java,Android,Imageview,Gesture,Ondraw,我正在开发一个应用程序,当用户双击图像时,它会在屏幕上画一个圆圈。我希望圆圈出现在用户点击屏幕的精确x和y坐标处。现在,它在屏幕的右上角绘制图像。我必须实现onTouchEvent吗?我该如何实现 以下是触控监听器:(触控是图像视图) 这是应该画圆圈的课程 class MyGestureDetector extends GestureDetector.SimpleOnGestureListener { public Context context; public MyGestureDetect

我正在开发一个应用程序,当用户双击图像时,它会在屏幕上画一个圆圈。我希望圆圈出现在用户点击屏幕的精确x和y坐标处。现在,它在屏幕的右上角绘制图像。我必须实现onTouchEvent吗?我该如何实现

以下是触控监听器:(触控是图像视图)

这是应该画圆圈的课程

class MyGestureDetector extends GestureDetector.SimpleOnGestureListener {
public Context context;

public MyGestureDetector(Context con)
{
    this.context=con;
}

@Override
public boolean onDoubleTap(MotionEvent event) {
     Bitmap bmOverlay = Bitmap.createBitmap(bitmap.getWidth(),
     bitmap.getHeight(),
     bitmap.getConfig());
     Canvas canvas = new Canvas(bmOverlay);
     Paint p = new Paint();
     p.setAntiAlias(true);
     p.setColor(Color.RED);
     p.setStrokeWidth(2);
     p.setStyle(Paint.Style.STROKE);
     canvas.drawBitmap(bitmap,new Matrix(),null);
     canvas.drawCircle(event.getX(),event.getY(),
            100, p);
     touch.setImageBitmap(bmOverlay);
    return false;
}
}

在MyGestureDetector类中,touch对象来自何处上述所有代码都位于同一个java文件imagedisplay.java中,“touch”对象是ImageView的对象
class MyGestureDetector extends GestureDetector.SimpleOnGestureListener {
public Context context;

public MyGestureDetector(Context con)
{
    this.context=con;
}

@Override
public boolean onDoubleTap(MotionEvent event) {
     Bitmap bmOverlay = Bitmap.createBitmap(bitmap.getWidth(),
     bitmap.getHeight(),
     bitmap.getConfig());
     Canvas canvas = new Canvas(bmOverlay);
     Paint p = new Paint();
     p.setAntiAlias(true);
     p.setColor(Color.RED);
     p.setStrokeWidth(2);
     p.setStyle(Paint.Style.STROKE);
     canvas.drawBitmap(bitmap,new Matrix(),null);
     canvas.drawCircle(event.getX(),event.getY(),
            100, p);
     touch.setImageBitmap(bmOverlay);
    return false;
}
}