• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Android: Handling touch events - pinch zoom on gallery

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic