Skip to content

Glide Compose ContentScale.FillWidth not work as expected #5338

@ag2s20150909

Description

@ag2s20150909

Glide Compose ContentScale.FillWidth not work as expected。There will be white space at the bottom and top. The image in the example below is only displayed once.

private val reusableModifier = Modifier
    .fillMaxWidth()
    .sizeIn(minHeight = 50.dp)
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun TestScreen(uri: String="https://images.pexels.com/photos/17850755/pexels-photo-17850755.jpeg"){
    Column(
        modifier = Modifier.fillMaxWidth(),
        verticalArrangement = Arrangement.Top

    ) {
        com.bumptech.glide.integration.compose.GlideImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )

        com.bumptech.glide.integration.compose.GlideImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )
    }
}

Result

The following is a comparison between coil.compose.AsyncImage and com.bumptech.glide.integration.compose.GlideImage

private val reusableModifier = Modifier
    .fillMaxWidth()
    .sizeIn(minHeight = 50.dp)
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun TestScreen(uri: String="https://images.pexels.com/photos/17850755/pexels-photo-17850755.jpeg"){
    Column(
        modifier = Modifier.fillMaxWidth(),
        verticalArrangement = Arrangement.Top

    ) {

        coil.compose.AsyncImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )
        coil.compose.AsyncImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )
        com.bumptech.glide.integration.compose.GlideImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )

        com.bumptech.glide.integration.compose.GlideImage(
            model = uri,
            contentScale = ContentScale.FillWidth,
            contentDescription = "",
            modifier = reusableModifier
        )
    }
}

Compare

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