-1

Crop Imageview and apply Rounded Corner

Kindly help me on this to crop the imageview and textview with rounded corner in android. (Eg: Attached sample image)

ADM
  • 20,406
  • 11
  • 52
  • 83
PrasathBabu
  • 4,716
  • 4
  • 19
  • 35

2 Answers2

2

You can try using CardView with app:cardCornerRadius equal to 1/2 of the height of the view.

Abhijeet Kumar
  • 343
  • 2
  • 8
0

If your min version allows it you can use a ViewOutlineProvider.

You can apply this to any kind of view meaning you can just put your image and text in a layout and make the circular clipping on the layout.

view.clipToOutline = true
view.outlineProvider = object : ViewOutlineProvider()
{
   @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
   override fun getOutline(view: View, outline: Outline) {
       outline.setOval(0, 0, view.width, view.height);
   }
}
Xavier Falempin
  • 1,186
  • 7
  • 19