在imageview上画圈

时间:2018-10-25 09:32:20

标签: java android canvas imageview

我正在尝试在图像上绘制一个圆,并绘制出一个圆,但并非完全在我触摸的触摸位置上。我该如何修改我的代码?

IV_MAP.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        dy = ((IV_MAP.getHeight() - mutableBitmap.getHeight() /2 ));
        dx = ((IV_MAP.getWidth() - mutableBitmap.getWidth() / 2 ));

        final float x = event.getX();
        final float y = event.getY();

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                tempCanvas.drawCircle(x-dx, y-dy , 10, mPaint);
                v.invalidate();  //set the dots on the pic
                dialog.show();
                break;   
}

0 个答案:

没有答案