TableView height: 'auto' not working.

You must Login before you can answer or comment on any questions.

I thought tableView would dynamically build its height with 'auto' I have the following code, my TableViewRow doesnt show unless I specify a height, am I missing something here?

var row = Ti.UI.createTableViewRow({
                height:'auto', 
            });
 
        var titleLabel = Ti.UI.createLabel({
            text: 'Row Title',
            color:'#362510',
            font:{fontSize:'18dp', fontWeight:'bold'},
            left:'3dp',
            top:'0dp',
            height: 'auto' ,
            width:Ti.Platform.displayCaps.platformWidth
 
        });
        row.add(titleLabel);
 
        topRowData.push(row);
 
        var topTable = Ti.UI.createTableView({
            data: topRowData,
            height:'auto'  // will show if I put value in there.
        });
 
win.add(topTable);
I have to have forgotten something, it doesnt jump out at me.

thanks

— asked 12 months ago by matt s
0 Comments

4 Answers

Try to add table without height property.

var topTable = Ti.UI.createTableView({
    data: topRowData
});

The auto height for a tableView is default to 0, and so often times it may not show up. What you are going to want to do is set the height property to this:

height : Ti.Platform.displayCaps.platformHeight

That checks for the height of the device (Note: In pixels), and then it will set your table's height correctly based upon that value.

You might try a height of Ti.UI.SIZE instead of auto. auto can be a little magic at times, but Ti.UI.SIZE is much more consistent (assuming you are using SDK 2.0 or newer). Not sure if it will work on Android or iOS, but I know it works on Mobile Web.

— answered 12 months ago by Bryan Hughes
answer permalink
1 Comment
  • Im using 1.8.2 and all my other tables I use

    height : Ti.Platform.displayCaps.platformHeight
    so not sure why I thought it woud auto size.

    — commented 12 months ago by matt s

Your Answer

Think you can help? Login to answer this question!