79547979

Date: 2025-04-01 07:35:13
Score: 0.5
Natty:
Report link
// each text is measured first and gets the space needed for it's content
// then the spacers are measured and divide up the space a close to the
// desired 1:3 or a 1:1:1 ratio as possible.
Row(modifier = Modifier.fillMaxWidth()) {
    Spacer(modifier = Modifier.weight(1f))
    Text(text = text1)
    Spacer(modifier = Modifier.weight(1f))

    Spacer(modifier = Modifier.weight(3f.takeIf{ text3 == null } ?: 1))
    Text(text = text2)
    Spacer(modifier = Modifier.weight(3f.takeIf{ text3 == null } ?: 1))

    text3?.let {
        Spacer(modifier = Modifier.weight(1f))
        Text(text = text3)
        Spacer(modifier = Modifier.weight(1f))
    }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Marcus