Specifically, is there a way to get the coordinates of the user's click relative to the top-left point of the ImageView?
Asked
Active
Viewed 54 times
-2
-
https://stackoverflow.com/questions/11312128/get-the-touch-position-inside-the-imageview-in-android - refer the answer that provides for this question – ML Madushanke May 14 '18 at 02:04
1 Answers
0
You can implement onTouchListener
to get the co-ordinates as follows:
imageButton.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();
});

Sagar
- 23,903
- 4
- 62
- 62
-
Right, I understand. But does this give the x and y coordinates relative to the top-left of the entire screen or to the top-left of the View itself? I'm looking for the latter. – Aryaman May 14 '18 at 02:02
-
1@Aryaman You can add on the top-left position of the `View v` screen coordinates if it was the screen position – OneCricketeer May 14 '18 at 02:07
-