I'm trying to put corners im my ImageView and I find these "workarounds":
1 - Take the Bitmap soure and paint then
2 - put a second ImageView on my layout and use shape+corners as its source
It's not possible take the image view and put a corner around then?
In my app i have a List with a lot of ImageView (the Bitmap used in this ImageView's is programmatically) and I want to put corners in every ImageView.
There is any other option?
You can create a selector
that contains shape
with rounded corners, and then apply it as the ImageView
's background using xml.
Look at this answers here
You can also do it via code by using PorterDuffXfermode
. PorterDuffXfermode
uses alpha compositing that will allow you to create and intersection (things of mathematical sets here) between the Canvas
you get from onDraw()
and an off screen Canvas
you will have to create. You will use one of the PorterDuff.Mode
flags to tell the framework you want to only render the pixels that intersect from the two Bitmaps
in each Canvas
.
More on Alpha Compositing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.