Skip to main content

Posts

Showing posts with the label Pinch Zoom

Android Basic Tutorial : Pinch Zoom

This Android tutorial will walk you through creating an application with pinch zoom feature.We will not use any external API support to implement the pinch zoom.We will use the ScalGestureDetectorclass to implement the zoom.It detects scaling transformation gestures using MotionEvent.We will get control in the application when the user pinches to zoom using the ScaleGestureDetector.OnScaleGestureListener interface.We should implement the onScale method in this GestureListener interface.AMatrixis constructed and scaled based on the user’s pinch gesture scale factor and then the ImageView set based on this scaled Matrix.


PinchZoomActivity.java

package com.example.android.pinchzoom.app;import android.app.Activity;import android.graphics.Matrix;import android.os.Bundle;import android.view.MotionEvent;import android.view.ScaleGestureDetector;import android.widget.ImageView;publicclass