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!
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 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
You can use ZoomableDraweeView for pinch-to-zoom feature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With