Titanium Community Questions & Answer Archive

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

TableViewRow height:'auto' ignores padding values.

Hi.
There seems to be something wrong in the calculation of a tableview's row height when using an additional padding for a label (at least on android).
It seems the padding (top and bottom values) is ignored when when using height:'auto'. Thus text gets cut off at the bottom.

You can see this behaviour in the KitchenSink example 'table_view_auto_height.js'. All code samples below are taken directly from this file.

The auto height TableViewRow is created like this:

data[0] = Ti.UI.createTableViewRow({hasChild:true,height:'auto'});

The auto height text label is added like this:

    data[idx].add(Ti.UI.createLabel({
        text:text,
        height:'auto',
        width:'auto',
        left:10,
        right:50,
        top:10,
        bottom:10
    }));

But the resulting TableViewRow with label gets cut off at the bottom by 20 pixels… is this really desired behaviour?
When setting the labels top and bottom values to 0 (or using a fixed height) the label gets displayed correctly.

Using the toImage() method to calculate the labels actual height as Ryan proposed here, then adding the desired padding value seems a bit over-the-top.

Any other known workarounds?

— asked June 3rd 2010 by Friedrich Seydel
  • android
  • auto
  • height
0 Comments

0 Answers

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.