私は持ってImageView
いますが、ユーザーが画像をクリック/タッチした場所をどのように確認できますか。
MotionEvent.getX()
とを使用する必要があることはわかっていMotionEvent.getY()
ますが、ユーザーが画像をクリックした場所を確認するにはどうすればよいですか?
ありがとう !
私は持ってImageView
いますが、ユーザーが画像をクリック/タッチした場所をどのように確認できますか。
MotionEvent.getX()
とを使用する必要があることはわかっていMotionEvent.getY()
ますが、ユーザーが画像をクリックした場所を確認するにはどうすればよいですか?
ありがとう !
画像ビューをサブクラス化し、ユーザーが触れている位置にインジケーターを明示的に描画する必要があります。
public class TouchableImageView extends ImageView {
// Constructors should come here
// Override onTouch to remember the touch position in our variable touchLocation
// Set touchLocation to null when getting the ACTION_UP event
// Override onDraw to draw something at touchLocation. You should create a proper Paint object
// in your constructors and use it here
public void onDraw(Canvas c) {
if (touchLocation!=null) {
canvas.drawCircle(touchLocation.x, touchLocation.y, 10, indicatorPaint);
}
}
private Point touchLocation;
private Paint indicatorPaint;
}