Nino
05/16/2024, 3:11 PMCrop
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 :
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
}
}
}
ephemient
05/16/2024, 3:31 PMRow(
modifier = Modifier
.height(IntrinsicSize.Min),
) {
Image(
painter = painterResource(R.drawable.big_image),
contentDescription = null,
modifier = Modifier
.weight(1f)
.fillMaxHeight(),
contentScale = ContentScale.FillHeight,
)
...
Nino
05/16/2024, 3:42 PMNino
05/16/2024, 3:44 PMephemient
05/16/2024, 3:55 PMephemient
05/16/2024, 4:03 PMRow(
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 sizeNino
05/16/2024, 4:21 PMConstraintLayout {
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 😞