0

I am developing an Android app in which I need to implement the following implementation.

suppose I have an image displayed on the screen (assuming to be a car),now then if I touch any part of the car ,suppose the wheels ,then it should display on the screen "The wheel" or something like that,similarly for other parts as well.

How to do that in android. What I have tried

I can display the image using image view .

I have the X and Y coordinates of the points am touching. I am clueless now,what should I do next ??

Nihar
  • 553
  • 1
  • 10
  • 29

1 Answers1

0

You can use getLocationOnScreen()

imageView.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View view) {
        int[] values = new int[2]; 
        view.getLocationOnScreen(values);
        Log.d("X & Y", values[0] + " " + values[1]);
        if(values[0] == Your_Point.x && values[1] == Your_Point.y) {
            // Apply your action..
        }
    }
});
Daniel Puiu
  • 962
  • 6
  • 21
  • 29
Virag Brahme
  • 2,062
  • 1
  • 20
  • 32
  • Yes.. and u can check if that point is what u r expecting for.. then apply ur action – Virag Brahme Dec 12 '13 at 13:26
  • but i have already my coordinates point . what i want next is if i touch any particular area (e.g the wheel of the car),then the screen should display "Its the wheel" or something like that – Nihar Dec 12 '13 at 13:28
  • The problem is I need to describe a complete area not a particular point.Any other idea ,do update. Anyway thanks for the help. – Nihar Dec 12 '13 at 13:48