Radoslaw Juszczyk
08/22/2023, 1:13 PM._height_(IntrinsicSize._Max_)
in some cases the first item in a Row
measures wrong.
Look at these three previews of the same composable but rendered with different widths: (picture below).
Not that it is ellipsized for 375dp width but not for 370 nor 380
(I am pasting minimum source code inside the thread)Radoslaw Juszczyk
08/22/2023, 1:14 PM@Preview(widthDp = 370, backgroundColor = 0xFFFFFFFF)
@Composable
fun width370() {
Test()
}
@Preview(widthDp = 375, backgroundColor = 0xFFFFFFFF)
@Composable
fun width375() {
Test()
}
@Preview(widthDp = 380, backgroundColor = 0xFFFFFFFF)
@Composable
fun width380() {
Test()
}
@Composable
fun Test() {
Surface {
val items = (0..3).map {
if (it % 2 == 1) {
"Cateogry $it"
} else {
"Two lines Cateogry $it"
}
}
Row(
modifier = Modifier.padding(horizontal = 16.dp).fillMaxWidth()
.height(IntrinsicSize.Max),
horizontalArrangement = spacedBy(16.dp),
) {
items.forEach {
Column(
modifier = Modifier.weight(1f).fillMaxHeight().border(2.dp, Color.Red),
verticalArrangement = spacedBy(16.dp),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f),
)
Text(
text = it,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
softWrap = true,
maxLines = 2,
)
}
}
}
}
}
Zach Klippenstein (he/him) [MOD]
08/22/2023, 6:56 PMRadoslaw Juszczyk
08/23/2023, 8:11 AMZach Klippenstein (he/him) [MOD]
08/25/2023, 4:05 PM