In my activity I reference ScrollView. According to the requirements, I should disable the inertial scrolling of ScrollView. How can I do that?
Asked
Active
Viewed 2,161 times
2 Answers
-1
These worked form me, but I'm not sure if it is good for performance.
What I did was create a new View extending the ScrollView and override the onTouchEvent method:
@Override
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()){
case ACTION_UP:
return false;
default:
return super.onTouchEvent(ev);
}
}
perhaps, you should also check the source code of the ScrollView to check if there is anything important else to do.
Here you have the source code at dispose:

Pablo
- 456
- 2
- 7
- 18
-5
Try this,
Scroll.setVerticalScrollBarEnabled(false);

MuraliGanesan
- 3,233
- 2
- 16
- 22
-
What I want to disable is inertial scrolling not the vertical scroll bar. Scroll.setVerticalScrollBarEnabled(false) will cause the vertical scroll bar can't be seen. – Li Bingqing May 22 '13 at 10:02
-
you cannot do that, see ScrollView sources and find a field called mScroller – pskink May 22 '13 at 12:58
-
Thank pskink very much.Then do you know the timing of inertial scrolling ? In my project,I will transform long-press key event to key down event.Then I handle the key down event(call the method scrollTo of ScrollView).Then I have noticed that after about 2-4 seconds of long-press,the inertial scrolling may appear.The precent is very low(about 5 percent).So I want to know the accurate timing. – Li Bingqing May 23 '13 at 03:26