Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to scroll ScrollView in top

Tags:

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!

like image 948
ihrupin Avatar asked Jun 07 '11 07:06

ihrupin


People also ask

How do I scroll to the top of ScrollView?

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.

How do I scroll to the top of my Android screen?

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.

How do I scroll to top programmatically?

scrollTo(0, 0); to scroll to the top of the NestedScrollView . You are welcome. This is more generally applied to both ScrollView or NestedScrollView.


2 Answers

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 
like image 66
dimas Avatar answered Oct 12 '22 08:10

dimas


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); 
like image 42
madhu527 Avatar answered Oct 12 '22 07:10

madhu527