Pinch-to-zoom with multi-touch gestures In Android

Trust Onyekwere
Quick Code
Published in
3 min readFeb 2, 2018

--

In this article, we will demonstrate multi-touch with the common pinch-to-zoom gesture using the SimpleOnScaleGestureListener class. The aim is to give you a head start if you intend to add pinch-to-zoom feature in your project.

The following screen-shot shows the icon zoomed in and out using the application created :

when zoomed in
when zoomed out

Okay, Let’s get started!.

  1. Create a new project in Android Studio and call it: Pinch2Zoom or whatever you like. Use the default Phone & Tablet options and select Empty Activity when prompted for the Activity Type.
  2. We’ll use an ImageView with the application icon to provide a visual indication of the pinch-to-zoom. Open activity_main.xml and Replace the existing TextView with the following ImageView :
<ImageViewandroid:id="@+id/imageView"android:layout_width="wrap_content"android:layout_height="wrap_content"

--

--

Trust Onyekwere
Quick Code

A human mingling around Blockchain 🔑 & Developer Relations 🎙️