There’s a clip modifier which can be applied to any composable as well as the Image
, just pass a CircleShape
into it:
Image(
painter = painterResource(R.drawable.sample_avatar),
contentDescription = "avatar",
contentScale = ContentScale.Crop, // crop the image if it's not a square
modifier = Modifier
.size(64.dp)
.clip(CircleShape) // clip to the circle shape
.border(2.dp, Color.Gray, CircleShape) // add a border (optional)
)
You can use any other shape to clip the image, for example CircleShape
it’s just RoundedCornerShape(percent = 50)
. Let’s try RoundedCornerShape(percent = 10)
: