horizontal layout and percentage width do not work well

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

titanium sdk: 2.1.1 os: mac os platfrom: iphone simulator 5.1

when the table row has a horizontal layout and the child view in it has a percentage width, the child view is not shown, take a look of the following code, button is presented, but the leftview is not:

var row = Ti.UI.createTableViewRow({
                    top:5,
                    bottom:5,
                    height : 60,
                    width: Ti.UI.FILL,
                    layout : 'horizontal',
                    selectionStyle: 'none'
                });
var leftView = Ti.UI.createView({
                    left : 0,
                    width : '75%',
                    height : 50,
                    layout : 'horizontal',
                    backgroundColor:'red'
})
var button = Ti.UI.createButton({
                    title : 'Button',
                    left : 0,
                    //top : '20%',
                    height : 30,
                    backgroundColor : '#104E8B',
                    color : '#FFFFF0',
                    font : {
                        fontSize : 14
                    },
                    style: Ti.UI.iPhone.SystemButtonStyle.PLAIN
});
 
row.add(leftView);
row.add(button);
tableView.appendRow(row);

— asked 8 months ago by kent hao
0 Comments

1 Answer

Accepted Answer

The TableViewRow only takes one view to display. If you want to make a complex row, wrap everything in a single view, then add that view to the row.

— answered 8 months ago by Anthony Decena
answer permalink
2 Comments
  • thanks for your answer. But i doubt that, because if i remove the layout property of the tableviewrow, the leftview and the button will be presented both.

    — commented 8 months ago by kent hao

  • I may have been mistaken about the number of views a row takes, but I am not mistaken about the best way to make a complex row. The best way to get the layout you want is to wrap everything in a wrapper view and add that view to the row. The wrapper view can have a horizontal layout and should work as expected.

    — commented 8 months ago by Anthony Decena

Your Answer

Think you can help? Login to answer this question!