How to draw a circular image in Android Jetpack Compose?

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)
)

enter image description here

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):

enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)