简体   繁体   中英

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?

this is Fresco ZoomableDraweeView

ZoomableDraweeView

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

ZoomableDraweeView-sample

Hope it help you!

您可以使用ZoomableDraweeView进行缩放缩放功能

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

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"));

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM