# compose

David Corrado

07/22/2022, 4:58 PM
Anyone know how to make compose where you have 2 different texts with large text work more like if you did it with the layout system or at least where the second text does not disappear. 🧵
In the layout legacy system it seems from testing with a constraintlayout it would make it so the 2 texts take 50% if they are both large. If the 2nd text is small it will just wrap and the 1st text will expand to take the extra space. Like is there a way to make compose work similar or at minimum not hide the second text?
Heres the compose example for reference
Copy code
Row(modifier = Modifier.fillMaxWidth()) {
    Text(text = "Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 Test3 ")
        "Blah blah blah",
        modifier = Modifier
I can manually do weights. But is there a means to make it automatic
Or if there are any blogs on this I would love to read through it if you find any. Not finding much by googling


07/22/2022, 5:06 PM
Looks like you want
weight(1f, fill = false)

David Corrado

07/22/2022, 5:08 PM
Yeah the problem with that is that it always will do 50/50 and not wrap the content of the text of the shorter one
Of course I could do different weights but I want it to be more of automatic. Do 50/50 unless there is something shorter then wrap that and use the available space


07/22/2022, 5:10 PM
you would do the weight only on one of the texts, the long one. Otherwise, if you have both text potentially being long, you may need to measure them and adjust the sizes after they've been measured. This could also be an option for a
(the equivalent to a
👆 1
🙏 1


07/22/2022, 5:12 PM
There was nothing “automatic” about this in the View system. If you used ConstraintLayout with Views and want to replicate that behavior, you should try Compose’s ConstraintLayout.
Otherwise Francesc’s solution of setting a weight on only one of the text widgets is correct, and how it would be done in
with Views
🙏 1

David Corrado

07/22/2022, 5:26 PM
Very interesting. I just verified yeah all works the same. Appreciate the clarification that weights are the way to go.

Oleksandr Balan

07/22/2022, 7:57 PM
Maybe it's worth to check this Layout implementation: Isn't it what you want to achieve?

Stylianos Gakis

07/22/2022, 10:49 PM
I was gonna link to that discussion as well. And if you want something to copy-paste to test asap give this a try. We've been using this for quite some time now in production and I'm super happy with how it turned out.
👍 1