I have a table with a bunch of contents, each “message” has different length so I try to position each group of contents even based on the height of the group. Somehow, the groups overlap when I use the groups height to position them but if I use a set height then it works fine but then I end up with a lot of white space instead since the variation of the heights.
How do I best position each group so they wont overlap?
[code]
for i = 1, #data do
local contentBox = display.newGroup()
local messageText = display.newText(contentBox, data[i].message, 0, 0, 280, 0, “Arial”, 14)
messageText:setReferencePoint(display.TopLeftReferencePoint)
messageText.x = 10;
messageText.y = 10;
messageText:setTextColor(255)
local contentBoxLine = display.newRect(contentBox, 0, 0, 300, 1);
contentBoxLine:setReferencePoint(display.TopLeftReferencePoint);
contentBoxLine:setFillColor(164, 152, 205, 255);
contentBoxLine.x = 0;
contentBoxLine.y = messageText.y + messageText.height + 20;
– Position the contentBox
contentBox:setReferencePoint(display.TopLeftReferencePoint);
contentBox.x = 10;
contentBox.y = (i-1) * contentBox.height + 40
print(" --> "…contentBox.height)
– insert the boxes to scrollView.
myScrollView:insert(contentBox)
end
[/code] [import]uid: 65840 topic_id: 28758 reply_id: 328758[/import]