I am building an app that displays text blocks of varied lengths from an external json file. I am using scrollview to display this text as scrollable, onscreen text. The first view works well but since I cannot change the scrollHeight once the object is created, It is creating a big gap at the bottom of some text segments.
Am I missing something or will I need to remove the object each time I want to refresh the text?
Here is how I am doing it:
– full function that makes the scroll object
local function initScroll()
gCollector[#gCollector+1] = {text=nil}
gCollector.text = widget.newScrollView
{
left = 0,
top = 100,
width = 280,
height = 300,
scrollWidth = 465,
scrollHeight = 470,
bottomPadding = 140,
hideBackground = true,
id = “onBottom”,
horizontalScrollDisabled = true,
verticalScrollDisabled = false,
listener = scrollListener,
}
end
– code that puts the text into the scroll object (Note, this is code within a larger function)
gCollector[#gCollector+1] = {cardText=nil}
gCollector.cardText = display.newText( gRecord.text, 0, 0, 200, 0, “Papyrus”, 16)
gCollector.cardText:setTextColor(0,0,0)
gCollector.cardText:setReferencePoint( display.TopLeftReferencePoint )
gCollector.cardText.x, gCollector.cardText.y = gCollector.cardText.width*.2, 0
gCollector.text:insert( gCollector.cardText )
– code that updates the text within the scrollview object (Note, this is code within a larger function)
gCollector.cardText.text = gRecord.text
gCollector.text:scrollToPosition({x = 1,y = 0,time = 0})
gCollector.cardText:setReferencePoint( display.TopLeftReferencePoint )
gCollector.cardText.x, gCollector.cardText.y = gCollector.cardText.width*.2, 0