skydoves / landscapist

🌻 A pluggable, highly optimized Jetpack Compose and Kotlin Multiplatform image loading library that fetches and displays network images with Glide, Coil, and Fresco.

Home Page:https://skydoves.github.io/landscapist/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ContentScale when inside ConstraintLayout works differently on 2.0.3 and 2.1.0

ABIlunar opened this issue · comments

When GlideImage is used inside a ConstraintLayout on 2.1.0, and contentScale is set to "Crop", it behaves as "Fit"

I have attached 2 images, where the only difference in code is the version bump from 2.0.3 to 2.1.0.

2.0.3
image

2.1.0
image (1)

Code snippet to reproduce


 ConstraintLayout(
            modifier = Modifier
                .clickable {
                    onClick()
                }
                .fillMaxWidth()
                .defaultMinSize(minHeight = 174.dp)
        ) {
            val (bottomRef, imageRef, backdropRef, topRightContentRef) = createRefs()

            GlideImage(
                imageModel = { imageUrl },
                modifier = Modifier.constrainAs(imageRef) {
                    top.linkTo(parent.top)
                    end.linkTo(parent.end)
                    bottom.linkTo(parent.bottom)
                    start.linkTo(parent.start)
                    width = Dimension.fillToConstraints
                    height = Dimension.fillToConstraints
                },
                imageOptions = ImageOptions(contentScale = ContentScale.Crop)
            )
        }




Due to fixing the #128 issue, you should specify fillMaxSize() if you want to match it to the parent composable.

Hello @skydoves, in version 2.1.1 still exist issue.

modifier = Modifier
                 .constrainAs(styleImage) {
                     start.linkTo(parent.start)
                     top.linkTo(parent.top)
                     end.linkTo(parent.end)
                     bottom.linkTo(title.top, 8.dp)
                     height = Dimension.fillToConstraints
                     width = Dimension.fillToConstraints
                 },

With this modifier in constraint layout the image doesnt fill all size. fillMaxSize() fix the issue but it is temp workaround