How to add width and height to url coil compose android

93 views Asked by At

AsyncImage(
                 model = url,
                 contentDescription = null,
                 modifier = Modifier.fillMaxSize(),
                 contentScale = ContentScale.Crop
         )

I would like to add width and height to the image url but I don't know how to do that. I tried .size parameter but it doesn't work. For Glide I used

.apply(RequestOptions()
                    .override(width, height)
                    .centerCrop())

but I don't know how to use it in coil.

1

There are 1 answers

4
ΓDΛ On

You can use the Modifier parameter.

AsyncImage(
    // other code
    model = ImageRequest.Builder(LocalContext.current)
    .data(url)
    .size(your size)
    .build(),
    modifier = Modifier
              .size(50.dp)
)