Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AsyncImage looks blurry when intrinsic measurement is used #2984

@StepByStepler

Description

@StepByStepler

Describe the bug
I have a composable function which contains AsyncImage and some content (just Box here for simplicity) in a Row. Box should define height of whole Row, so I use intrinsic measurement here. This causes AsyncImage to look blurry. If I manually specify height of AsyncImage to match height of Box, image looks good, but it's not possible in my real layout (which is deeply nested).

To Reproduce
This function reproduces the bug:

@Composable
fun TestContent() {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .height(IntrinsicSize.Min),
    ) {
        AsyncImage(
            model = "https://img.cdn.level.travel/hotels/9067545/ea1882c778888d649bc9e44d1336d6e6.jpg",
            contentDescription = null,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .width(64.dp)
                .fillMaxHeight(),
        )

        Box(
            modifier = Modifier
                .weight(1f)
                .height(120.dp)
                .background(Color.Red),
        )
    }
}
Image

While this doesn't:

@Preview
@Composable
fun TestContent() {
    Row(
        modifier = Modifier
            .fillMaxWidth(),
    ) {
        AsyncImage(
            model = "https://img.cdn.level.travel/hotels/9067545/ea1882c778888d649bc9e44d1336d6e6.jpg",
            contentDescription = null,
            contentScale = ContentScale.Crop,
            modifier = Modifier
                .width(64.dp)
                .height(120.dp), // manually copy height of Box to AsyncImage
        )

        Box(
            modifier = Modifier
                .weight(1f)
                .height(120.dp)
                .background(Color.Red),
        )
    }
}
Image

Version
I'm using Coil version 3.2.0 and Android Compose version 1.9.0-alpha02

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions