Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can implement zoom in Fresco Library?

I'm using Fresco to visualize images from the assets folder in a view. My problem is that by default the class com.facebook.drawee.view.SimpleDraweeView doesn't have a zoom/pinch method. Is there any property or something in the XML to enable this, or which is the way to achieve it?

like image 348
Víctor Martín Avatar asked Aug 26 '15 09:08

Víctor Martín


4 Answers

this is Fresco ZoomableDraweeView

ZoomableDraweeView

To see how to use please take a look at this:

ZoomableDraweeView-sample

Hope it help you!

like image 132
Chuong Nguyen Avatar answered Nov 11 '22 16:11

Chuong Nguyen


PhotoDraweeView enables double tap and pinch zoom (similar to the PhotoView library) to the Fresco library.

Add the photodraweeview dependency in the app gradle:

dependencies {
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'me.relex:photodraweeview:1.1.3'
}

replace the XML code:

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/my_image_view"
    android:layout_width="130dp"
    android:layout_height="130dp"
    fresco:placeholderImage="@drawable/my_drawable"/>

with

<me.relex.photodraweeview.PhotoDraweeView
    android:id="@+id/my_image_view"
    android:layout_width="130dp"
    android:layout_height="130dp"
    app:placeholderImage="@drawable/my_drawable"/>

In the java code onCreate() set the url:

PhotoDraweeView mPhotoDraweeView = findViewById(R.id.my_image_view);
mPhotoDraweeView.setPhotoUri(Uri.parse("http://your.image.url"));
like image 37
Mridulpj Avatar answered Nov 11 '22 18:11

Mridulpj


The fresco's ZoomableDraweeView sample added some new features such as double-tap to zoom and enable scrolling in ViewPager when the ZoomableDraweeView zooms in. I've wrote a demo for this sample in which I've also optimized some default behaviors to make it more perfect.

Please refer to: https://github.com/ibosong/CommentGallery

like image 22
Bos Avatar answered Nov 11 '22 18:11

Bos


You can use ZoomableDraweeView for pinch-to-zoom feature

like image 38
Samir Avatar answered Nov 11 '22 16:11

Samir