ScrollView: Cannot scroll to the top.

I tried to create chat app that every message submitted will be pushed upside. I’m using scrollView to handle the message history but when there are about 10 items, it stuck!! I tried submit number 1 to 10 each line but I cannot scroll to see number 1 in the first line. This is my assumption, I observed that every time I pushed up each line element, the first line’s y coordinate will decrease until it’s lower than 0. But I don’t know how to fix it.

Any help would be appreciated.

Thanks

Hi @jademwit,

How are you positioning the new message “upside”? Do you move all of the previous messages down to make room? Or do you scroll the entire scrollView down, then place the new message at top?

Best regards,

Brent

I used display.newtext and subtract y value of each element. I placed the new message below other elements above text field.

Hi @jademwit,

What I would suggest is that you shift the previous messages down as a collective group, instead of scrolling the scrollView down. Then, place the new message above all of these. Finally, use “:setScrollHeight()” to update the total scrollable height of the widget to the total height of all messages combined.

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

Brent

I will tried it. Thank you very much Brent :slight_smile:

Hi, It’s still bug. Is there anyway I can scroll up to see the old message. Below is image show the bug.

image.jpg?noCache=1410088766

As you see in the image above, you will see half of number 1 because I cannot scroll up to see it full.

when you declare your scrollview in the options say topPadding = 30 (play with number) you should also do this for your bottomPadding 

http://docs.coronalabs.com/api/library/widget/newScrollView.html#toppadding-bottompadding-optional

Hi @jademwit,

How are you positioning the new message “upside”? Do you move all of the previous messages down to make room? Or do you scroll the entire scrollView down, then place the new message at top?

Best regards,

Brent

I used display.newtext and subtract y value of each element. I placed the new message below other elements above text field.

Hi @jademwit,

What I would suggest is that you shift the previous messages down as a collective group, instead of scrolling the scrollView down. Then, place the new message above all of these. Finally, use “:setScrollHeight()” to update the total scrollable height of the widget to the total height of all messages combined.

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

Brent

I will tried it. Thank you very much Brent :slight_smile:

Hi, It’s still bug. Is there anyway I can scroll up to see the old message. Below is image show the bug.

image.jpg?noCache=1410088766

As you see in the image above, you will see half of number 1 because I cannot scroll up to see it full.

when you declare your scrollview in the options say topPadding = 30 (play with number) you should also do this for your bottomPadding 

http://docs.coronalabs.com/api/library/widget/newScrollView.html#toppadding-bottompadding-optional