hello everyone I am developing application and I have a girl and boy avatar .. I want to issue action like Alert Dialog if he touch specific coordinates in the avatar how to do that without drawing canvas ?? any help please !!
Asked
Active
Viewed 80 times
-1
-
Why aren't you using `ImageView` to show girl and boy avatar. Moreover you'll know which avatar is clicked as `ImageView` has `onClickListener` – Akshay Chordiya May 10 '17 at 10:12
-
Get coordinates from view matrix [See here](http://stackoverflow.com/questions/43672370/android-i-want-to-get-different-x-y-position-on-touch-when-canvas-scale-and-tran/43673019#43673019) – Vijay Pal Vishwakarma May 10 '17 at 10:24
-
@AkshayChordiya I already used ImageView I want to issue event depend on specific coordinates in that imageView , are you the one who voted for not useful question ? – Reem Aziz May 10 '17 at 15:56
-
Nope. Not me. I'm already trying to help you. – Akshay Chordiya May 10 '17 at 16:36
-
oh , I am sorry . I just was thinking if my question stupid or something , apologize – Reem Aziz May 10 '17 at 16:39
1 Answers
1
View YOUR_VIEW = findViewById(R.id.MY_VIEW);
YOUR_VIEW.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i("Coordinates:", " X: " + String.valueOf(event.getX()) + " , Y: " + String.valueOf(event.getY()));
return true;
}
});

Mehran Zamani
- 831
- 9
- 31
-
but I want to issue action depends on a group of coordinates ?? like if he touch the mouth of the avatar show hem alert !! – Reem Aziz May 10 '17 at 16:25
-
for that, you should have coordinates of the mouth or somewhere else! – Mehran Zamani May 11 '17 at 05:49