https://kotlinlang.org logo
#compose
Title
# compose
g

galex

07/31/2020, 5:54 PM
Is there a way to tell an Image to be round?
b

Brett Best

07/31/2020, 5:56 PM
Like rounded corners?
g

galex

07/31/2020, 5:58 PM
Yes! To make it a circle, basically
b

Brett Best

07/31/2020, 6:00 PM
I think you achieve this using the modifier parameter
e

Eric Ampire [MOD]

07/31/2020, 6:06 PM
Copy code
@Composable
fun Picture(imageRes: Int) {
    val image = imageResource(id = imageRes)
    val pictureModifier = Modifier
            .padding(10.dp)
            .clip(androidx.ui.foundation.shape.corner.CircleShape)
            .preferredSize(200.dp)

    Image(
        asset = image,
        modifier = pictureModifier
    )
}
You have just to clip the image with the circle shape, like in this code
g

galex

07/31/2020, 6:10 PM
Thank you! I was wondering how the Modifier is called!