Android:如何在顶部滚动ScrollView

ihr*_*pin 20 android

我有两个按钮切换到下一个事件列表和前一个事件列表.

当我去下一个\上一个事件时,滚动仍然在下面的某个地方.但我需要"倒回"它.

我尝试着:

scrollViewEventDetails.pageScroll(ScrollView.FOCUS_UP);
Run Code Online (Sandbox Code Playgroud)

和:

scrollViewEventDetails.scrollTo(0, 0); 
Run Code Online (Sandbox Code Playgroud)

但它不起作用.请帮忙!

小智 31

你应该写下一个:

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
Run Code Online (Sandbox Code Playgroud)


mad*_*527 21

这不适合我:

scrollViewEventDetails.fullScroll(View.FOCUS_UP); //if you move at the end of the scroll
Run Code Online (Sandbox Code Playgroud)

这对我有用:

scroll_view.smoothScrollTo(0,0);
Run Code Online (Sandbox Code Playgroud)


Ash*_*Ash 14

scrollview.pageScroll(View.FOCUS_UP);更加一致并为我工作.:)