9

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?

uday
  • 1,348
  • 12
  • 27
Víctor Martín
  • 3,352
  • 7
  • 48
  • 94

5 Answers5

8

this is Fresco ZoomableDraweeView

ZoomableDraweeView

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

ZoomableDraweeView-sample

Hope it help you!

  • 1
    I've read it.But the effect of zoom is not good.When zoom out, the viewpager can't scroll.And it seems to be not supporting gif. – Allen Vork Jul 13 '16 at 08:37
3

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"));
Mridulpj
  • 33
  • 2
  • 9
  • And it doesn't work and if you press to many times on the picture with multipile fingers the application will crash. – f.trajkovski Oct 20 '18 at 16:19
2

You can use ZoomableDraweeView for pinch-to-zoom feature

Samir
  • 3,139
  • 2
  • 17
  • 24
1

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

Bos
  • 365
  • 2
  • 13
0

The other answers do not have double tap to zoom functionality. I've built a library that works for double tap to zoom and pinch to zoom Fresco Zoom

Arlind Hajredinaj
  • 8,380
  • 3
  • 30
  • 45