is there a bug in Row() that doesn’t prioritize th...
# compose
m
is there a bug in Row() that doesn’t prioritize the sizes correctly when using Overflow on text? Simplest example, with 2 texts (one text and one Icon will do the same. It only clips the text if its the last item in the row.
s
What would you expect to happen here instead?
m
if any text allows for clipping (ir. textOverflow is set ) that one should only be given the remaining space and then clip
its worse when I have a text and an Icon, since the icon actually have a specific size, but the text will push out the icon before it starts clipping
s
So would Row need to know the internals of its children to pick up if they have TextOverflow set in order to measure them accordingly? That would be quite confusing for it to be the default behavior no?
Could you try and instead be explicit about what you want from your row? If there is an item which wants to be measured last, after the rest of the components are already laid out in the available space, you can put a
weight(1f)
on it. That way row will place the other items, and will give all of the remaining space to the item with the weight
If potentially both of those two texts(or whatever) can go over the other one, and you do not want either one to “trample over” the other one, consider using a layout like this https://github.com/HedvigInsurance/android/blob/4eeb8aee6c28bba871551e2ac005bc411f[…]ig/android/core/ui/text/HorizontalItemsWithMaximumSpaceTaken.kt instead (Original solution by Albert here https://kotlinlang.slack.com/archives/CJLTWPH7S/p1650525026461549?thread_ts=1648467352.438719&cid=CJLTWPH7S)
m
but weight 1 will always take up the rest of the space. If I want the text to be packed together if they are short, but one should be clipped if one takes to much space, then weight(1f) wont work
I guess the issue is that Row does not have a modifier that fits here .
if row had a priority modifier, then I could resort the calculation order.
a
Modifier.weight(1f, fill = false)
is what you want.
m
oh, forgot about the fill.. let me check.
s
image.png,image.png
m
👍 Thanks, that will help me with this