Handling varied length text using scrollview

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

Do you have more than 1 text blocks that you would like to scroll one after the other? Or are you trying to place 1 scrollView on the screen that will be just the right height and then use the remaining space on your screen for other UI elements? Its not very clear what the ultimate goal is. Kindly clarify. 

It is kind of quote generator where random quotes get inserted into a single text field. sometimes the quotes are 20 lines at other times, the quotes are 50. The scroll widget is actually within a display object.

text => scrollview => displayObject => screen

The text in confined to a fixed screen rect and is scrollable within the defined rect. The rest of the screen is stationary. 

Do you have more than 1 text blocks that you would like to scroll one after the other? Or are you trying to place 1 scrollView on the screen that will be just the right height and then use the remaining space on your screen for other UI elements? Its not very clear what the ultimate goal is. Kindly clarify. 

It is kind of quote generator where random quotes get inserted into a single text field. sometimes the quotes are 20 lines at other times, the quotes are 50. The scroll widget is actually within a display object.

text => scrollview => displayObject => screen

The text in confined to a fixed screen rect and is scrollable within the defined rect. The rest of the screen is stationary.