Table views, rows, dynamic height?
Hey!
I'm trying to make a table view, where each row has a title and summary. Both of these things can have multiple lines.
I can't seem to get anything to work without items overlapping each other.
Is there a way to construct a table in such a way that the summary is placed after the title, no matter what the height of the title is?
And is there a way to make the table row adjust its size according to how much space the title/summary takes up?
3 Answers
-
Accepted Answer
You can stack labels by setting
layout:'vertical'
on the row andheight:'auto'
on each label. Use thetop
property on each label to specify padding.The row will adjust its own size if you set
height:'auto'
on the row as well. You may want to specifyminRowHeight
on the table view to ensure a measure of consistency for the ordinary case. -
You should be able to set the row height to "auto" to adjust the height based on its content.
As for stacking labels dynamically one over the other, I don't have a good solution for that. You can place them side by side by restricting their widths and setting the label height to auto.
If your labels have the same formatting, you could just use one label and combine the strings with a return character in between. -
Warning, I've found auto height labels and vertical layouts buggy. I think it all depends on what your tables look like though. In some of my table views (grouped section), I have a not small number of different types of grouped sections and it has a lot of visual artifacts.
I would give it a try though and see if you get lucky. You can also seriously consider using elided fields (yes, I know, not optimal).