Dynamic content in scrollView object

Hoping someone can point me to a resource to figure out how to tackle this.

I have a storyboard with a scrollView object. Within that scrollView I have a number of text objects but the problem is that each text object can vary in length so setting y position to a fixed value won’t work.

Any suggestions on how best to tackle? Thanks

Make a list of them, insert one at a time, and use the previous text object’s y coordinate and height to get the next one’s. Snippet from my own code solving the same problem:

 local textDisplayObjects = {} for i = 1, #textList local txt = display.newText{text = textList[i], x = 0, y = 0, width = 380, font = native.systemFont, fontSize = 22} txt.anchorX, txt.anchorY = 0, 0 table.insert(textDisplayObjects, txt) if(i \> 1) then txt.y = textDisplayObjects[i - 1].y + textDisplayObjects[i - 1].height + 5 end end

Thanks for unblocking my mental bottleneck and sharing your code memo. Text object height is the key that eluded me!

Make a list of them, insert one at a time, and use the previous text object’s y coordinate and height to get the next one’s. Snippet from my own code solving the same problem:

 local textDisplayObjects = {} for i = 1, #textList local txt = display.newText{text = textList[i], x = 0, y = 0, width = 380, font = native.systemFont, fontSize = 22} txt.anchorX, txt.anchorY = 0, 0 table.insert(textDisplayObjects, txt) if(i \> 1) then txt.y = textDisplayObjects[i - 1].y + textDisplayObjects[i - 1].height + 5 end end

Thanks for unblocking my mental bottleneck and sharing your code memo. Text object height is the key that eluded me!