I have a bunch of content that I have added to a scrollView with the help of a for loop, the problem is that the objects overlap because they are of different height.
How do I position all objects so they don’t overlap anymore?
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
/thanks
Cin [import]uid: 65840 topic_id: 28934 reply_id: 328934[/import]