https://kotlinlang.org logo
#compose
Title
# compose
d

dimsuz

02/01/2022, 12:10 AM
I'm not sure if the behaviour I'm seeing is the bug in the intrinsic measurements, but it's certainly something that had me confused for several hours. tl;dr: adding an
Icon
results in Row with intrinsic height having a half-cut-out text. Sample in the thread.
Copy code
Row(modifier = Modifier.width(180.dp).height(IntrinsicSize.Min)) {
  Column(
    modifier = Modifier.background(Color.Gray)
      .weight(2/3f)
      .fillMaxHeight()
  ) {
    Icon(imageVector = Icons.Default.Check, contentDescription = null)
    Text(text = "hello world and foo bar")
  }
  Column(
    modifier = Modifier.background(Color.Green)
      .weight(1/3f)
      .fillMaxHeight()
  ) {
    Icon(imageVector = Icons.Default.Check, contentDescription = null)
    Text(text = "hello")
  }
}
result is this:
but if I add a
Modifier.size(24.dp)
to `Icon`s (or even remove them), then calculations seem to start to work:
If I have the top
Row
fill max width and no modifiers on icons, then text even won't show up at all. only icons. It was very confusing initially. Is this the expected behavior?
a

Albert Chang

02/01/2022, 2:21 AM
3 Views