• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android: Handling touch events - pinch zoom on gallery

 
Cormac Ffff
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am writing some code to allow pinch zoom on an image gallery on an android app. When pinching images in the gallery the image should zoom. And when moving left or right over images they should move between different images in the gallery.

The problem I am having is knowing when a MotionEvent is a pinch event or just a normal touch event.

I know that if an event is a pinch (multitouch) event then it will contain a ACTION_POINTER_DOWN action and if it is a normal single touch event that it won't.

However, if an event is a single touch event then I need to return false in the onTouchEvent method to allow the parent gallery to handle the event. But when I 'return false' I can then no longer check if the event contains an ACTION_POINTER_DOWN action.

Can I check if the MotionEvent contains an ACTION_POINTER_DOWN action before the event gets to the onTouchEvent method?

Or is there another way to always return true if it is a multitouch event and return false if it is a single touch event?

See code below:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic