If the first Text is too wide it shrinks my second...
# compose
s
If the first Text is too wide it shrinks my second Text. Instead of "9999" only one "9" is shown for example. How can I achieve that the second Text always takes the required space and the first Text get's shrinked/overflows if there is not enough space? I tried
defaultMinSize
, but that has not the effect I expected.
Copy code
Row(
    verticalAlignment = Alignment.CenterVertically
) {

    Text(
        text = text
    )

    Spacer(
        modifier = Modifier.weight(1.0f)
    )

    Text(
        text = photoCount.toString(),
        maxLines = 1,
        modifier = Modifier.padding(horizontal = defaultPadding).border(1.dp, Color.Red)
    )
}
👀 1
1
m
you can add
weight(1f)
modifier to the second text, so that it takes remaining space
s
Ok, but then it shares the space if the existing spacer. And if there is no space left because the first text is too wide it still gets shrinked.
I'm looking for a "take your required space and do not shrink" modifier, but I don't see one.
a
You could remove the space, add the
weight(1f)
to the first text and make sure the first text is left-aligned, this should work
🙏 1
The first text will take all leftover space, but since it's leftaligned it will not be noticable
s
Ah, I see. Thank you. 🙂