开发者

pinch to zoom multi-touch feature in Android

Hello Everybody,

I was searching Android multitouch (pinch zoom) in so many sites but couldn't find any appropriate answer, I have found one link http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html in which he suggested to use private ScaleGestureDetector mScaleDetect开发者_如何学Pythonor; but ScaleGesturesDetector requires android 2.2 froyo. Then what will we do for below 2.2. Is there any example code or solution ?

your valuable time will be helpful to me ..thanks in advance


Due to the varying levels of support for multitouch on earlier Android devices (i.e. generally none), I'd suggest that if ScaleGestureDetector is not available on the device, you simply provide on-screen zoom in/out buttons.

This page gives a good explanation of how you can detect if certain APIs are available (i.e. ScaleGestureDetector on 2.2 and higher), allowing your app to degrade gracefully if they're not (i.e. with buttons if lower than 2.2) http://blog.radioactiveyak.com/2011/01/how-to-use-gyroscope-api-and-remain.html


This should be possible just be expanding on the code provided in the blog you linked to (if there are multi-touch phones running pre-2.2 Android). If you take the example just before the one introducing the Gesture Detectors, you have much of what you need.

As for the actual theory of it, it shouldn't be too difficult. Firstly detect when two fingers are both on screen. In the first instance, store the positions of these fingers as the start positions. Then, for each movement with two fingers still on screen, compare the current positions with the stored start positions, and zoom in/out accordingly.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜