views:

734

answers:

4

Hi there,

I just wanted to know if there is some kind of class to use the multitouch features of android 2.1. Specifically I am trying to implement pinch-zoom and was wondering if I always have to measure the distance between two touch events and calculate the zoom level on my own?

Thanks, chris

A: 

There have been hacks created by developers that enable multitouch on the browser and Dolphin browser. These come in custom roms and I am sure that they are downloadable.

Also Google has released multi-touch officially on the Nexus One and Motorola on their milestone. This means that you should be able to get an official class for it but I bet that its for version 2.1 of Android.

Also I think that it would be safe to assume that you want this to work on rooted phones. Than means that you may be stuck at using Android 2.1 and maybe all the way down to 2.0.

Jonathan Czitkovics
The question is about Android development. This site is about software development. Your answer is for end users.
CommonsWare
@CommonsWare: This is very much about software development. If the API isn't there for Android 2.0 but is for Android 2.1, it does affect the outcome of his development.
Andrew Moore
+2  A: 

I believe you will need to calculate the zoom level yourself. This article looks like a good resource to get you started: http://blogs.zdnet.com/Burnette/?p=1847

mbaird
I think Ed Burnette (author of that post) goes into greater detail in his upcoming third edition of his book, Hello, Android.
CommonsWare
+3  A: 

I'm trying to do the same thing, and as usual my first instinct was to look into the Android source code itself. The interesting bits seem to be in class ScaleGestureDetector, which is not public but its javadoc says

@hide Pending API approval

so hopefully it will become public at some point.

Update: ScaleGestureDetector is now part of the Android 2.2 API.

Mirko Nasato
A: 

Are you trying to zoom into a picture? As a simple solution, you could use a WebView to display your image, it has built-in pinch-zoom functionality.

molnarm