Detecting pinch in Android

大城市里の小女人 提交于 2020-01-01 08:24:30

问题


I would like to handle pinch events in my Android application to zoom in and out.

I believe Android 2.0 has multi-touch functionality, and heard that Android 1.6 might or might not support it depending of the device.

What's the best way to detect pinch events, while degrading gracefully for devices that don't support it? I'm targeting Android 1.5 upwards.


回答1:


A great article by Ed Burnette (Hello Android Author) on multi touch (including pinch zoom) can be found here: http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2/1747

Here's an article on the Android developer blog about taking advantage of capability of the newer APIs on devices that support them, while gracefully continuing to support older devices. http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html




回答2:


Android 1.6 does not support multi-touch, Android 2.0 and above does, that means that you would need to have different OnTouchHandlers that you can swap in based on the version of Android you detect. For more information about how to implement the pinch-zoom, have a look at this thread.



来源:https://stackoverflow.com/questions/2631567/detecting-pinch-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!