Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Anrdroid Pinch Zoom Possible?


Is pinch to zoom and panning an image possible with Titanium in Android?

I've been trying various different suggestions that seem to lead to things not currently working for android.
Is there a work around?

I was thinking of trying to do it myself but it seems Multi touch isn't supported for Android either.

In my application I need to display images that can be zoomed and panned in a manner that people have come to associate with touch screen devices.

I look forward to some answers so that I can either put time into developing this functionality or continue with other tasks in the hope that by the time I come to the end there might be some support for it or a workaround.

I suppose I'm a little tired of putting time into something only to realise it isn't supported or there is no way it can work. Running out of time for this project.

— asked November 25th 2010 by Kevin
  • android
  • image
  • multi
  • pinch
  • touch
  • zoom

1 Answer

  • Kevin

    You can keep up to date with the progress made on the pinch gesture for android by watching ticket #1540.

    Instead, why not use doubletap for the zoom, changing the image dimensions at each event, and a scrollView to allow the user to pan around the view area?


    — answered November 25th 2010 by Paul Dowsett
    • Thanks for the reply Hal,

      I have explored this option but as I found out after a few tries and some digging around the scrollView on android only allows scrolling in one direction. From what I can gather this is not an issue on Iphone and it just works.

      I had tried a combination of doubletaping an imageView and having canScale set to true with the zoom controls false, This allows you to zoom the image but as soon as you start to pan around the image pans within its original dimensions.
      You get the same effect if you use the zoom controls ie the zooming and panning occurs within the original space.

      With the device in landscape mode, You load a portrait image with the height set to auto (so there is blank space either side, doubletap to zoom, it zooms up to fill the screen, when you start to pan the areas that were blank maintain the static zoomed image while the panning occurs within the space that the image originally occupied.

      The only other way I can think of now is to get the start and end points of a touch gesture and translate that into an animation to move the image by that amount. But from looking around I'm not sure if touch gestures are fully supported for Android.

      — commented November 26th 2010 by Kevin
    • I would really like to implement something as this is a big part of the application I'm developing ie viewing and zooming in on hi res images to show more detail.

      — commented November 26th 2010 by Kevin
    • I just had a thought for a workaround:
      I could have my images on a html page with a link to open the native browser rather than a webView. I would need to open a chromeless version of the browser though.

      — commented November 26th 2010 by Kevin
    • Any updates on ticket #1540?

      I can't get passed the login screen when I click the link.

      I would like to use pinch and zoom.

      — commented May 25th 2011 by Kurt Williams
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.