I used Glide library to load image into imageView and I don't know how to make image pinch to zoomable

This library here called PhotoView is quite popular.
https://github.com/chrisbanes/PhotoView

With 13,500+ stars, 30+ contributors backing it, so many people using it and how easy it is to integrate into a project, it almost feels like a standard.

It's also compatible with Glide ^.^


Installation (Official documentation by chrisbanes)

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

Then, add the library to your module build.gradle

dependencies {
    implementation 'com.github.chrisbanes:PhotoView:latest.release.here'
}

At that time of writing, latest.release.here is 2.1.4.


Usage (Official documentation by chrisbanes)

There is a sample provided which shows how to use the library in a more advanced way, but for completeness, here is all that is required to get PhotoView working:

<com.github.chrisbanes.photoview.PhotoView
    android:id="@+id/photo_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);

That's it!


Usage with Glide

Nothing changes!!

PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
Glide.with(this).load(imageUrl).into(photoView);

You can for example use this library. https://github.com/MikeOrtiz/TouchImageView

Load your image into this widget, instead of ImageView

Sample usage:

private TouchImageView mContentView;
private private SimpleTarget target;

mContentView = (TouchImageView) findViewById(R.id.fullscreen_content);

target = new SimpleTarget<Bitmap>() {
        @Override
   public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) 
{
            // do something with the bitmap
            // for demonstration purposes, let's just set it to an ImageView
            mContentView.setImageBitmap(bitmap);
        }
    };



    Glide.with(this) // could be an issue!
            .load( imagePath )
            .asBitmap()
            .into(target);

Notice, that i also use SimpleTarget first, it is good practice for using Glide and pinch to zoom effect for large images.

And the layout will be something like this:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.FullscreenActivity">


<com.yourPath.TouchImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/fullscreen_content"/>

</FrameLayout>

Also, sometimes there is an issue with loading the image after this setup. For me works something like this. I override the method from TouchImageView class:

@Override
public void setImageBitmap(Bitmap bm) {
    imageRenderedAtLeastOnce = false;
    super.setImageBitmap(bm);
    savePreviousImageValues();
    fitImageToView();
}