Gabrielle
Gabrielle

Reputation: 4981

Detect which part of an imageView was touch?

Is it possible to detect on android what part of an image (right, left) was touched?

Upvotes: 1

Views: 1069

Answers (3)

banzai86
banzai86

Reputation: 747

Or you put 2 buttons behind your ImageView, then you have the click handler included directly

Upvotes: 0

MrJre
MrJre

Reputation: 7161

sure, attaching a touch listener will allow you to handle the MotionEvent, which contains the actual touch position; just do something like if(event.getX() < image.width / 2) { // touch on left } else { // touch on right; }

Upvotes: 2

Raz
Raz

Reputation: 9058

If you use TouchEvent you can get the x and y of the touch.

Upvotes: 1

Related Questions