Image loaded badly in SimpleDraweeView with frescolib in android

325 Views Asked by At

I am using frescolib on my application to load images from url. However, I am experiencing a problem within the objects of the recyclerview. Specifically I need to center the images in SimpleDraweeView while keeping the format. So I'm using the following code, but I get the streaked, stretched images in the part that should be white.

this is wrong loaded image

this is original image

My code:

RoundingParams roundingParams = RoundingParams.fromCornersRadius(50f);
        GenericDraweeHierarchy hierarchy =
                GenericDraweeHierarchyBuilder.newInstance(activity.getResources())
                        .setRoundingParams(roundingParams)
                        .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE)
                        .setFailureImage(ContextCompat.getDrawable(activity,R.drawable.ic_image_off))
                        .setProgressBarImage(ContextCompat.getDrawable(activity,R.drawable.animview))
                        .build();
        this.imageView.setHierarchy(hierarchy);
        this.imageView.setImageURI(uri);

Any idea why the image is loaded badly?

1

There are 1 best solutions below

1
Alexander Oprisnik On

This is a Fresco limitation when the image does not cover the full viewport that will be fixed with the next Fresco release (2.7.0).

In the meantime, you can either change the scale type or use the overlay color rounding mode instead fi you have a solid background as a workaround for now (which should be possible looking at your screenshot):

RoundingParams roundingParams = RoundingParams.fromCornersRadius(50f);
roundingParams.setOverlayColor(yourBackgroundColorInt);
...

Fresco is using a BitmapShader which repeats the edge pixels that causes this issue. More information: https://frescolib.org/docs/rounded-corners-and-circles.html#caveats