How to make an ImageView with rounded corners?

前端 未结 30 2597
天涯浪人
天涯浪人 2020-11-21 05:39

In Android, an ImageView is a rectangle by default. How can I make it a rounded rectangle (clip off all 4 corners of my Bitmap to be rounded rectangles) in the ImageView?

30条回答
  •  梦谈多话
    2020-11-21 06:30

    You should extend ImageView and draw your own rounded rectangle.

    If you want a frame around the image you could also superimpose the rounded frame on top of the image view in the layout.

    [edit]Superimpose the frame on to op the original image, by using a FrameLayout for example. The first element of the FrameLayout will be the image you want to diplay rounded. Then add another ImageView with the frame. The second ImageView will be displayed on top of the original ImageView and thus Android will draw it's contents above the orignal ImageView.

提交回复
热议问题