Pinch-to-zoom with multi-touch gestures
The previous recipe used the SimpleOnGestureListener
to provide detection of simple, one-finger, gestures. In this recipe, we will demonstrate multi-touch with the common pinch-to-zoom gesture using the SimpleOnScaleGestureListener
class.
The following screenshot shows the icon zoomed out using the application created in the following recipe:

The following screenshot shows the icon zoomed in:

Getting ready
Create a new project in Android Studio and call it: MultiTouchZoom
. Use the default Phone & Tablet options and select Empty Activity when prompted for the Activity Type.
How to do it...
To provide a visual indication of the pinch-to-zoom, we'll use an ImageView
with the application icon. Open activity_main.xml
and follow these steps:
Replace the existing
TextView
with the followingImageView
:<ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher...