I\'m using fresco to display images in a list view. however i have an issue.
when i scale my image using methods that maintain aspect ratio like CENTER_CROP, and the
I strongly recommend that you read the Fresco documentation. All of your questions here are already answered there.
Drawee view does not support ImageView attributes (adjustViewBounds, getImageMatrix, etc.). See the documentation.
Read about intrinsic dimensions, again, in the documentation here.
If you really need to dynamically resize your view, with all of the disadvantages that come with that, you can do that by using a controller listener as explained here.
Hope that helps and let me know should you have any more questions.
In order to make simpledraweeview resize, this is what i implemented a ControllerListener
and changed simpleDraweeView
height as desired.
private void loadImage(Uri fileUri,final SimpleDraweeView simpeDraweeView) {
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources());
GenericDraweeHierarchy hierarchy = builder
.setProgressBarImage(new CircleProgressBarDrawable())
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
.build();
ImageRequest requestBuilder = ImageRequestBuilder.newBuilderWithSource(fileUri)
.setProgressiveRenderingEnabled(true)
.build();
ControllerListener<ImageInfo> contollerListener = new BaseContollerListener<ImageInfo>() {
public void onFinalImageSet(String id, ImageInfo imageinfo,Animatable animatable) {
if(imageinfo != null) {
updateViewSize(imageinfo)
}
}
DraweeContoller contoller = Fresco.newDraweeContollerBuilder()
.setContollerListener(contollerListener)
.setImageRequest(requestBuilder)
.build();
simpleDraweeView.setHierarchy(hierarchy);
simpleDraweeView.setController(contoller);
}
private void updateViewSize(ImageInfo imageinfo){
//this is my own implementation of changing simple-drawee-view height
// you canhave yours using imageinfo.getHeight() or imageinfo.getWidth();
simpleDraweeView.getLayoutParams().height = imageinfo.getHeight();
// don't forget to call this method. thanks to @plamenko for reminding me.
simpleDraweeView.requestLayout()
}