I'm load a picture using Glide
in my project, but I found a strange thing. When I use into(ImageView)
, the ImageView
displays not the same with what when using into(new BitmapImageViewTarget(centerImageView))
:
This is my layout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/center_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
When I use :
String imageUrl = "http://7xlz1k.com1.z0.glb.clouddn.com/feedback-201604229711.png";
Glide.with(this).load(imageUrl).into(centerImageView);
The ImageView's wrap_content
doesn't work, it displays like this:
But when I use :
Glide.with(this).load(imageUrl).asBitmap().into(new BitmapImageViewTarget(centerImageView));
The ImageView looks :
The image contained in the imageUrl
is a 120*120 picture.
And when I use the BitmapImageViewTarget
, the default animation doesn't work.
Three questions:
Why is there the difference between the two methods?
How can I make the ImageView's wrap_content
useful when using the first method?
And How can I make the default animation enable when using the BitmapImageViewTarget
?
I will try give a solution for your second question:
- How can I make the ImageView's wrap_content useful when using the first method?
I managed to make wrap_content working by adding adjustViewBounds to the ImageView's layout:
<ImageView
android:id="@+id/center_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true" />
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