I have two buttons that switching to the next list of events and the previous one.
When I go to next\previous event, scrolls remains somewhere below. But I need to "rewind" it up.
I'm trying:
scrollViewEventDetails.pageScroll(ScrollView.FOCUS_UP);
and:
scrollViewEventDetails.scrollTo(0, 0);
but it doesn't work. Please, help!
To scroll to top of the ScrollView with React Native, we assign a ref to the ScrollView and call scrollTo on the ref's value. to create a ref with useRef and set that as the value of the ref prop of the ScrollView . Then we add a Button that calls ref. current.
When you're at the bottom of a page, just tap the left side of your status bar to instantly scroll back up to the top. Tap the right trigger area, and you'll be taken directly to the bottom of any page.
scrollTo(0, 0); to scroll to the top of the NestedScrollView . You are welcome. This is more generally applied to both ScrollView or NestedScrollView.
You shoud write next:
scrollViewEventDetails.fullScroll(View.FOCUS_UP);//if you move at the end of the scroll scrollViewEventDetails.pageScroll(View.FOCUS_UP);//if you move at the middle of the scroll
This did not work for me:
scrollViewEventDetails.fullScroll(View.FOCUS_UP); //if you move at the end of the scroll
This worked for me:
scroll_view.smoothScrollTo(0,0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With