Skip to content
Related Articles

Related Articles

PhotoView in Android

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 18 Feb, 2021

In this article, PhotoView is added in android. PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView using multi-touch and double-tap. Besides that, it has many more features like it notifies the application when the user taps on the photo or when the displayed matrix gets changed. It provides smooth scrolling even when a scrolling parent container like ViewPager is used. It can be used in the gallery app. 

Step 1: Add the support Library in your root build.gradle file (not your module build.gradle file). This library jitpack is a novel package repository. It is made for JVM so that any library which is present in github and bigbucket can be directly used in the application. 


allprojects {           
 repositories {           
        maven { url '' }           

Step 2: Add the support library in build.gradle file and add the dependency in the dependencies section. It allows the developer to use the PhotoView directly in XML files. 


dependencies {           
     implementation 'com.github.chrisbanes:PhotoView:2.0.0'          

Step 3: Add the following code in the activity_main.xml file. In this file, PhotoView is added to the layout.


<?xml version="1.0" encoding="utf-8"?>

Step 4: Add the following code in the file. In this file, we add image to our PhotoView.  setImageResource() method is used to add the image in PhotoView.

package org.geeksforgeeks.photoView          
import android.os.Bundle;
import com.github.chrisbanes.photoview.PhotoView;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        PhotoView photoView = (PhotoView)


 Refer to the official documentation for more information.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!