How to make an ImageView with rounded corners?

前端 未结 30 2482
天涯浪人
天涯浪人 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:28

    A quick xml solution -

    
    
        
    
    
    

    You can set your desired width, height and radius on CardView and scaleType on ImageView.

    With AndroidX, use

提交回复
热议问题