Hi, I want to add equally spaced labels to a tableview for header and content like an excel list. But somehow the header seems to behave different than the content. The header starts left, but the content is shifted to the right. What is the correct code to do this?
app.tss
".LabelCell" : { top : Alloy.Globals.Style.p2, font: { fontSize: Alloy.Globals.Style.FontSize, }, bottom : Alloy.Globals.Style.p2, textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT, left:Alloy.Globals.Style.p5, width : Alloy.Globals.Style.p25, height: Ti.UI.SIZE, } ".rowView" : { width: Ti.UI.SIZE, height: Ti.UI.SIZE, layout : "horizontal", } ".headerView" : { width: Ti.UI.SIZE, height: Alloy.Globals.Style.p9, layout : "horizontal", backgroundColor:"#86bad9", } ".tableViewGames" : { width: Alloy.Globals.Style.TableViewWidth, height: Ti.UI.SIZE, scrollable : false, }addPlayers.xml
<Alloy> <Window> <ScrollView> <View> <View id="playersView" class="groupView"> <TableView id="players" class="tableViewGames"/> </View> </View> </ScrollView> </Window> </Alloy>addPlayer.js
var addRow=function(name,join) { var row = Ti.UI.createTableViewRow(); row.hor = $.UI.create('View',{ classes: 'rowView', }); row.add(row.hor); row.nameLabel= $.UI.create('Label',{ classes: "LabelCell", text : name, }); row.hor.add(row.nameLabel); row.statusLabel= $.UI.create('Label',{ classes: "LabelCell", text : join, }); row.hor.add(row.statusLabel); return row; }; var section = Ti.UI.createTableViewSection(); var hor=$.UI.create('View',{ classes: 'headerView', }); var nameLabel= $.UI.create('Label',{ classes: "LabelCell", text : 'Name', }); hor.add(nameLabel); var statusLabel= $.UI.create('Label',{ classes: "LabelCell", text : 'Status', }); hor.add(statusLabel); section.headerView=hor; dataPlayers.push(section); var i=0; for (var user_id in status.users) { var user=status.users[user_id]; var row=addRow(user.name,status.users[user_id].join); dataPlayers.push(row); i++; } for (var r=0;r<status.random;r++) { var row=addRow('random','waiting'); dataPlayers.push(row); i++; } $.players.setData(dataPlayers);