fresco icon indicating copy to clipboard operation
fresco copied to clipboard

RoundingParams.setBorder(..) does not work

Open azfarsiddiqui opened this issue 11 years ago • 7 comments

I am not able to show a border to an image. Neither through code, nor XML.

    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
    RoundingParams roundingParams = RoundingParams.fromCornersRadius(25.0f).setBorder(android.R.color.holo_red_dark, 2.0f);
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(1000)
            .setRoundingParams(roundingParams)
            .setPlaceholderImage(getResources().getDrawable(R.drawable.ic_launcher))
            .build();

    imageView.setHierarchy(hierarchy);
    imageView.setImageURI(uri);

azfarsiddiqui avatar Mar 27 '15 13:03 azfarsiddiqui

Do you see the rounded corners correctly? Is it just the border that is the problem?

IanChilds avatar Mar 27 '15 17:03 IanChilds

Also, if you add .setOverlayColor(0xFFFFFF00) while building RoundingParams, what happens? This will help us diagnose where the issue might be.

plamenko avatar Mar 27 '15 19:03 plamenko

@IanChilds, I was able to round the image with the code I provided. I am currently only able to circle an image by using:

RoundingParams.asCircle()

@plamenko, If I use setOverlayColor() in conjunction with RoundingParams.asCircle(), the rectangular area holding the circle is painted using that overlay color. However, that color is not drawn over the actual image itself.

if I use setOverlayColor in conjunction with RoundingParams.fromCornersRadius(), there is no effect at all, as the image is itself rectangular therefore no area is left to be filled by the color.

azfarsiddiqui avatar Mar 28 '15 03:03 azfarsiddiqui

Alright, I think i've narrowed down the problem. The setBorder() method seems to ignore android color references. For example If I run the following, I don't get expected result:

    RoundingParams roundingParams = RoundingParams.fromCornersRadius(25.0f).setBorder(android.R.color.holo_blue_bright, 5.0f);

However, when I remove the color reference and provide the color value directly, it works as expected:

    RoundingParams roundingParams = RoundingParams.fromCornersRadius(25.0f).setBorder(0xff00ddff, 5.0f);

azfarsiddiqui avatar Mar 28 '15 03:03 azfarsiddiqui

Yes, this should be ARGB color, not a resource reference. Both of those use int type, and it makes more sense to interpret it as a color than as a resource id.

plamenko avatar Mar 28 '15 03:03 plamenko

You can always get the color value from the resource id with getResources().getColor(R.color.holo_blue_bright) I'm glad that you resolved the issue.

plamenko avatar Mar 28 '15 03:03 plamenko

Thanks a lot @plamenko..

azfarsiddiqui avatar Mar 28 '15 03:03 azfarsiddiqui