I have a basic Image with a painterResource from my drawale folder.
I'm trying to make it a rounded image but the clip modifier isn't doing anything.
This is one way I've tried.
@Composable
fun roundImage(){
Image(
painter = painterResource(id = R.drawable.profilepicexample),
contentDescription = null,
modifier = Modifier
.fillMaxSize(0.2f)
.clip(CircleShape),
contentScale = ContentScale.Crop
)
}
I've also tried putting the image in a box/card and clipping that but it still does nothing!
What am I missing here?
Update: Current Code
@ExperimentalMaterialApi
@Composable
fun AdminPeopleLocationsScreen(modifier: Modifier, navController: NavController){
val appRepo = AppRepository()
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
){
Image(
painter = painterResource(id = R.drawable.bgtest),
contentDescription = null,
modifier = Modifier
.fillMaxWidth(0.4f)
.aspectRatio(1f)
.clip(CircleShape),
contentScale = ContentScale.Crop
)
}
}
Screenshot:

update 2: Still stuck on this, playing around I found that it shows the clipping in a @Preview but removes it on the device.
I was facing the same issue and this worked to me:
@Composable
fun MyImageAdvance() {
val image = painterResource(R.drawable.ic_launcher_background)
Column(
modifier = Modifier
.fillMaxWidth()
.height(200.dp)
.padding(16.dp)
) {
Image(
painter = image,
contentDescription = "my description for disabled people",
contentScale = ContentScale.Crop,
modifier = Modifier
.clip(CircleShape)
)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With