In my activity I reference ScrollView. According to the requirements, I should disable the inertial scrolling of ScrollView. How can I do that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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);
}
}
I don't know watch happens it alter the state machine that control scrolling and movement on the view, but it works.
perhaps, you should also check the source code of the ScrollView to check if there is anything important else to do.
If you wish to pursue such endeavour, here you have the source code at dispose:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/ScrollView.java
回答2:
Try this,
Scroll.setVerticalScrollBarEnabled(false);