Android ScrollView 禁用惯性滚动 [英] Android ScrollView disable Inertial scrolling
本文介绍了Android ScrollView 禁用惯性滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的活动中,我引用了 ScrollView.根据要求,我应该禁用ScrollView的惯性滚动.我该怎么做?
In my activity I reference ScrollView. According to the requirements, I should disable the inertial scrolling of ScrollView. How can I do that?
推荐答案
这些对我有用,但我不确定它是否对性能有好处.
These worked form me, but I'm not sure if it is good for performance.
我所做的是创建一个扩展 ScrollView 的新视图并覆盖 onTouchEvent 方法:
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);
}
}
也许,您还应该检查 ScrollView 的源代码以检查是否还有其他重要的事情要做.
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:
这篇关于Android ScrollView 禁用惯性滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文