I'm trying to handle a user touch listener on my image, I want to store all XY coordinates of an image view which touched pixels. as this image, senario : user touch an image in first touch, I want to store XY coordinates then user touch the same image for the second touch , also I want to store XY coordinates and so on.mobile screen
Hope it help!
public class Coordinate {
float x;
float y;
public Coordinate(float x, float y) {
this.x = x;
this.y = y;
}
}
ArrayList<Coordinate> coordinates = new ArrayList<>();
yourImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//int eventAction = event.getAction();
//switch (eventAction) {
// case MotionEvent.ACTION_DOWN:
// break;
// case MotionEvent.ACTION_UP:
// break;
// case MotionEvent.ACTION_MOVE:
// break;
//}
coordinates.add(new Coordinate(event.getX(), event.getY()));
return false;
}
});