0

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?

Elvis Oliveira
  • 941
  • 2
  • 15
  • 29

1 Answers1

0

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

Community
  • 1
  • 1
Emmanuel
  • 13,083
  • 4
  • 39
  • 53
  • And how can i retriever this selector programmatically and set a BMP as its drawable resource? – Elvis Oliveira Apr 04 '14 at 15:39
  • You will not retrieve the selector, you will set it as the `background` of the `ImageView` and then add the `Bitmap` to the `ImageView` via code. – Emmanuel Apr 04 '14 at 15:41