-1

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 !!

Reem Aziz
  • 1,425
  • 2
  • 17
  • 22
  • 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 Answers1

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