Content Width Area Of New Scrollview Widget Not Dynamic?

I’ve got a scrollView; I’ve got a group that I insert into the scrollView, and I’ve got objects that I insert into the group. 

When I want to “refresh” my scrollView, I call a function that remove the objects from the group.

local function limpaScrollDer() local i local function onScrollToComplete() print( "Completed" ) end for i=grupoScrollDer.numChildren,1,-1 do grupoScrollDer[i]:removeSelf() grupoScrollDer[i] = nil end scrollViewDer:scrollTo("top",{ time = 500, onComplete = onScrollToComplete }) end

And then I starts inserting other objects into my group.

If are the same number of objects (all the objects has the same height) everything is ok, but if there are more or less objects (so I expect the scrollview’s height adapts) I get the same height, so if there are less objects I gets blank space and if if there are more objects I can’t scroll across all of them.

Ok Danny!

I’ve solved it.

I had this line before starting to insert the objects into the group:

scrollViewDer:insert(grupoScrollDer)

I put this line after inserting the objects and seems it works fine.

Thanks!

Hello,

I’m getting the same issue as Oliver but with the height (I’m using a vertical scroll). I add content with scrollView:insert(object) and my scroll grows correctly, but when I remove objects, the scroll doesn’t adapt to the new height.

Has this issue been solved?

Thanks.

what build of corona are you using? This was fixed a while ago

build 2013.1095

I’ve got a scrollView; I’ve got a group that I insert into the scrollView, and I’ve got objects that I insert into the group. 

When I want to “refresh” my scrollView, I call a function that remove the objects from the group.

local function limpaScrollDer() local i local function onScrollToComplete() print( "Completed" ) end for i=grupoScrollDer.numChildren,1,-1 do grupoScrollDer[i]:removeSelf() grupoScrollDer[i] = nil end scrollViewDer:scrollTo("top",{ time = 500, onComplete = onScrollToComplete }) end

And then I starts inserting other objects into my group.

If are the same number of objects (all the objects has the same height) everything is ok, but if there are more or less objects (so I expect the scrollview’s height adapts) I get the same height, so if there are less objects I gets blank space and if if there are more objects I can’t scroll across all of them.

Ok Danny!

I’ve solved it.

I had this line before starting to insert the objects into the group:

scrollViewDer:insert(grupoScrollDer)

I put this line after inserting the objects and seems it works fine.

Thanks!

Did this ever get solved. I have a vertical scrollview in which the user has the option to delete rows. When I remove content my scrollview doesn’t update it’s height. How would I achieve a ‘refresh’ on the scrollview?

Hi @juliusbangert,

One method I would suggest is that you adjust the scrollView’s scroll height on-the-fly when a user removes rows/content.

So basically, get the scrollView’s view reference via “scrollView:getView()”:

https://docs.coronalabs.com/api/type/ScrollViewWidget/getView.html

[lua]

local view = scrollView:getView()

[/lua]

Then, when something changes (content is removed), query the view for its overall content height:

[lua]

print( view.contentHeight )

[/lua]

Then, using that value, set the new scroll height via “scrollView:setScrollHeight()”:

https://docs.coronalabs.com/api/type/ScrollViewWidget/setScrollHeight.html

Hope this helps,

Brent

Did this ever get solved. I have a vertical scrollview in which the user has the option to delete rows. When I remove content my scrollview doesn’t update it’s height. How would I achieve a ‘refresh’ on the scrollview?

Hi @juliusbangert,

One method I would suggest is that you adjust the scrollView’s scroll height on-the-fly when a user removes rows/content.

So basically, get the scrollView’s view reference via “scrollView:getView()”:

https://docs.coronalabs.com/api/type/ScrollViewWidget/getView.html

[lua]

local view = scrollView:getView()

[/lua]

Then, when something changes (content is removed), query the view for its overall content height:

[lua]

print( view.contentHeight )

[/lua]

Then, using that value, set the new scroll height via “scrollView:setScrollHeight()”:

https://docs.coronalabs.com/api/type/ScrollViewWidget/setScrollHeight.html

Hope this helps,

Brent