coil-kt/coil

Image displayed at placeholder aspect ratio

Open

#1.505 geöffnet am 11. Okt. 2022

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Kotlin (757 Forks)batch import
help wanted

Repository-Metriken

Stars
 (11.779 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 20h 14m) (28 gemergte PRs in 30 T)

Beschreibung

Describe the bug It appears that using a combination of Placeholder, Crossfade and ContentScale.FillWidth will cause an image to be displayed at the placeholder aspect ratio and not the final image.

To Reproduce The test_image drawable in this case is a 16:9 image

@Composable
fun Sample() {
    Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState())) {
        //Correct aspect ratio
        AsyncImage(
            modifier = Modifier.fillMaxWidth(),
            model = ImageRequest.Builder(LocalContext.current)
                .data("https://s3.amazonaws.com/www-inside-design/uploads/2020/10/aspect-ratios-blogpost-1x1-1.png")
                .placeholder(R.drawable.test_image)
                .crossfade(false)
                .build(),
            contentDescription = null,
            contentScale = ContentScale.FillWidth
        )

        Spacer(Modifier.height(16.dp))

        //Incorrect aspect ratio
        AsyncImage(
            modifier = Modifier.fillMaxWidth(),
            model = ImageRequest.Builder(LocalContext.current)
                .data("https://s3.amazonaws.com/www-inside-design/uploads/2020/10/aspect-ratios-blogpost-1x1-1.png")
                .placeholder(R.drawable.test_image)
                .crossfade(true)
                .build(),
            contentDescription = null,
            contentScale = ContentScale.FillWidth
        )
    }
}

Logs/Screenshots Screenshot_20221011-165830

Version Reproduced on both 2.0.0 and 2.2.2, using a Pixel 6 Pro on Android 13

Contributor Guide