I came up with this very annoying layout issue.
Basically the UI component I’m looking for is not that complex, but the behavior needs to be exact.
In all cases I have 2 or 3 texts I need to layout horizontally.
In best case scenario all of these 3 fit in one line, so layout is not a problem.
| text 1 < empty space> | text 2 | < empty space> text 3 |
But when I hit an issue that text1 needs more than 1 lines, I should set that column 0 stretchable for TableLayout at the same time text2 might also need more than 1 lines so that column also needs to be stretchable and I would need the result to be like this:
| text1 many lines taking 40% | text2 takes 20% | text 3 many lines takes 40% |
And when this issue comes I haven’t found a way to set TableLayout shrink and stretch columns. And also problem is that TableRow can contain 2 or 3 children.
I did few hour testing playing with LinearLayout and onGlobalLayout I calculated how much which is taking and adjusted weights of those views, but that’s very complex and not working always, width on view3 sometimes just returned zero when view1 was very long.
I’m looking for some tips where to start here, should I do layouts in xml and inflate them instead programmically making them etc.
Okay I found out the solution, column 0 shrinkable, column 1 stretchable and tablerow span 2 for tablerow child number 2 if only 2 childs.