Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting pinch in Android

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.

like image 671
hpique Avatar asked Apr 13 '10 17:04

hpique


People also ask

How to detect gestures in Android?

Detect gestures. Android provides the GestureDetector class for detecting common gestures. Some of the gestures it supports include onDown() , onLongPress() , onFling() , and so on. You can use GestureDetector in conjunction with the onTouchEvent() method described above.

How do you pinch on Android?

The pinch key on the emulator is the Alt key. Hold down Alt and click and drag your mouse button.

How do you use pinch gestures?

This pinch gesture is achievable using PinchGestureHandler from the library itself. This handler tracks the distance between two fingers and uses that information to scale or zoom in on the content. It gets activated when the fingers are placed on the screen and when their position changes.

What is pinch zoom in Android?

Pinch 2 or more fingers together or apart to adjust zoom. To zoom temporarily, quickly tap the screen 3 times and hold down your finger on the third tap. Drag your finger to move around the screen. Lift your finger to zoom out.


1 Answers

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

like image 128
Damian Avatar answered Sep 30 '22 02:09

Damian