Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked March 31st 2010 by Will Collins
  • row
  • table
0 Comments

3 Answers

  • Accepted Answer

    You can stack labels by setting layout:'vertical' on the row and height:'auto' on each label. Use the top 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 specify minRowHeight on the table view to ensure a measure of consistency for the ordinary case.

    — answered March 31st 2010 by James K
    permalink
    0 Comments
  • 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.

    — answered March 31st 2010 by Sunder Iyer
    permalink
    0 Comments
  • 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).

    — answered March 31st 2010 by David Crawford
    permalink
    1 Comment
    • I am having the same issue when I use "vertical" layout all my labels inside the row disappear.

      — commented September 23rd 2011 by Leonardo Amigoni
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.