我可以在图像中创建一个点,但是当我在 canvas.drawCircle(touchX,touchY, 2, paint) 中将坐标指定为 touchx,touchy 时,我无法在我触摸过的地方创建圆点,还有这个功能应该仅在单击图像时起作用,但是当我触摸图像外部时它的创建点以及当我触摸屏幕时图像正在缩放...我想不应该缩放的图像并且应该仅在触摸图像时创建点。 .请帮助...
imageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
touchX = (int) (event.getX());
touchY = (int) (event.getY());
ImageView imageView = (ImageView) findViewById(R.id.imageView2);
Bitmap bitMap = Bitmap.createBitmap(100,100, Bitmap.Config.ARGB_8888);
bitMap = bitMap.copy(bitMap.getConfig(), true);
Canvas canvas = new Canvas(bitMap);
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
imageView.setImageBitmap(bitMap);
imageView.setBackgroundResource(R.drawable.image_map);
canvas.drawCircle(50, 60, 2, paint);
imageView.invalidate();
return true;
}
});