Coil: How to get a rounded image with a border

Created on 14 Apr 2020  路  2Comments  路  Source: coil-kt/coil

I've tried to use the built in RoundedCornerTransformation but I also want to draw a border. Which is the best way to get it? As a temporary solution I've wrapped the imageview in a MaterialCardView.

Could I get better performances using a transformation?

Thank you very much!

question

Most helpful comment

Thank you very much! I found out I can use a ShapeableImageView from Material Components to get the same result without wrapping an imageview into a card.

All 2 comments

Coil doesn't support setting a border with RoundedCornerTransformation out of the box. You'll have to write a custom Transformation to use support that.

In terms of performance, Transformations will be faster in some cases, but slower in others. For rounded corners it would be faster to clip the image when drawing the bitmap on a View's canvas. This is because adding a Transformation forces Coil to return a software bitmap instead of a hardware bitmap. Overall, I wouldn't worry about performance, though; both should be fast.

Thank you very much! I found out I can use a ShapeableImageView from Material Components to get the same result without wrapping an imageview into a card.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doilio picture doilio  路  3Comments

mario picture mario  路  3Comments

cioccarellia picture cioccarellia  路  3Comments

SourabhSNath picture SourabhSNath  路  3Comments

theScrabi picture theScrabi  路  5Comments