Home > database >  Set modifier height width to coil Image or AsyncImage and scal the image loaded from url
Set modifier height width to coil Image or AsyncImage and scal the image loaded from url

Time:08-26

I'm using coil library to load images in my composable view and I want to define fix height and width for my coil Image composable, however the modifier is missing in the coil Image composable class, following is the code snippet I'm using.

AsyncImage(
        model = limit.imgUrl,
        contentDescription = null
    )

How I can make the width and height fixed irrespective of the image resolution.

CodePudding user response:

Just apply modifier = Modifier.height(xx.dp).width(xx.dp) to the AsyncImage:

   AsyncImage(
        //...
        modifier = Modifier.height(300.dp).width(100.dp)
    )
  • Related