I have an imageView with width:match_parent and height:wrap_content. I want the image with full width and keep the ratio for the height.
I follow this link (https://github.com/nostra13/Android-Universal-Image-Loader/pull/62) who say to set adjustviewbounds and center_crop on my imageView and set imageScaleType to ImageScaleType.EXACTLY_STRETCHED.
So i do that :
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.showImageForEmptyUri(R.drawable.cache_waiting)
.showImageOnFail(R.drawable.cache_waiting)
.showStubImage(R.drawable.cache_waiting)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.build();
setAdjustViewBounds(true);
setScaleType(ScaleType.CENTER_CROP);
ImageLoader.getInstance().displayImage(img.getUrl(), this,defaultOptions);
With this code, most of ImageView are white. The logcat tell me the bitmap is too large (2560,1120). How can I keep the ratio of images with UIL.
Thanks,
I also config as you. But ImageView should :
<ImageView
android:id="@+id/thumb_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
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