Introduction

In this article, we are going to see how to obtain Zoom View in Android using Android Studio. Zooming view is a famous library used widely through over the world used to provide a zoomed view of a given image.
Step 1
Create a new project in Android Studio.
Android
Give a name to the project and click "Next".
Android
Select the "Phone and Tablet" and click "Next".
Android
Select an empty activity and click "Next".
Android
At last, give the activity name and click on "Finish".
Android
Step 2
Next, copy the image in .png format
Android
Locate app>>res>>drawable folder and paste the copied image into the drawable folder.
Android
Step 3
Locate the Gradle Scripts>>Build. Gradle 1
Android
And type the following dependency in your app's build.gradle.
Android
Code copy is here,
  1. repositories {
  2. maven { url "https://jitpack.io" }
  3. }
Step 4
Locate the Gradle Scripts>>Build. Gradle 2
Android
And type the following dependency in your app's build.gradle.
Android
The code copy is here.
  1. dependencies {
  2. implementation 'com.github.chrisbanes:2.1.3'
  3. }
Step 5
Next, go to app >> res >> layout >> activity_main.xml. Select activity page.
Android
And, just type the code as follows.
Android
The code copy is here.
  1. <com.github.chrisbanes.photoview.PhotoView
  2. android:id="@+id/photo_view"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"/>
Step 6
Next, go to app >> java>>Mainactivity.java. Select Mainactivity page.
Android
And check whether it is default or else make it default.
Android
The code copy is here.
  1. PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
  2. photoView.setImageResource(R.drawable.developer);
Step 7
Verify the preview.
->After the code is applied, the preview will appear like this.
Android
Step 8
Next, go to Android Studio and deploy the application. Select an Emulator or your Android mobile with USB debugging enabled. Give it a few seconds to make installations and set permissions.
Android
Run the application in your desired emulator (Shift + F10).
Android
Explanation of source code
The code used in the activity_main.xml is used to insert the image into our app and it is also used to define its width, height, and gravity.

Summary

We created a new app named zoom view and placed the image in the drawable folder. After that, we have inserted the Gradle dependencies to build Gradle and verified the deployed output.