I'm trying to `Crop` an `Image` while constraining...
# compose
n
I'm trying to
Crop
an
Image
while constraining its width to be 1/3 of the
Row
it's inside (and height as big as the row), but since the source image is so big, it takes all the height of the screen. How can I do it ?
Modifier.height(IntrinsicSize.Min)
doesn't seem to work. My code :
Copy code
Card(modifier = modifier.fillMaxWidth()) {
    Row {
        Image(
            painter = painterResource(R.drawable.big_image),
            contentDescription = null,
            modifier = Modifier.weight(1F),
            contentScale = ContentScale.Crop,
        )
        Column(modifier = Modifier.weight(2F)) {
            // Some stuff with a dynamic height
        }
    }
}
e
Copy code
Row(
    modifier = Modifier
        .height(IntrinsicSize.Min),
) {
    Image(
        painter = painterResource(R.drawable.big_image),
        contentDescription = null,
        modifier = Modifier
            .weight(1f)
            .fillMaxHeight(),
        contentScale = ContentScale.FillHeight,
    )
    ...
n
It's still the same issue
image.png
e
oh testing it out, it's the painter's intrinsic size that's doing that
Copy code
Row(
    modifier = Modifier
        .height(IntrinsicSize.Min),
) {
    Spacer(
        modifier = Modifier
            .weight(1f)
            .fillMaxHeight()
            .paint(
                painter = painterResource(R.drawable.big_image),
                sizeToIntrinsics = false,
                contentScale = ContentScale.Crop,
            ),
    )
    ...
will ignore the image's intrinsic size
n
Even with ConstraintLayout it doesn't work either :
Copy code
ConstraintLayout {
    val startGuideline = createGuidelineFromStart(0.3f)
    val (image, title) = createRefs()

    Image(
        painter = ColorPainter(Color.Red),
        contentDescription = null,
        modifier = Modifier
            .constrainAs(image) {
                top.linkTo(<http://parent.top|parent.top>)
                start.linkTo(parent.start)
                bottom.linkTo(parent.bottom)
                end.linkTo(startGuideline)
            }
            .height(200.dp),
    )

    Text(
        text = "Compose is great",
        modifier = Modifier.constrainAs(title) {
            top.linkTo(<http://parent.top|parent.top>)
            start.linkTo(startGuideline)
            bottom.linkTo(parent.bottom)
        }
    )
}
It's nowhere near 30% of the width wtf 😞