简体   繁体   English

Android:如何检测滚动结束

[英]Android: How to detect end of scroll

I need to implement HorizontalScrollView which is scrolled to predefined positions (similar to Home behaviour). 我需要实现将Horizo​​ntalScrollView滚动到预定义位置(类似于家庭行为)。 It works with slow gestures, but does not work with neither flings nor arrow key press. 它适用于慢速手势,但不适用于猛击或箭头键按下。

I hooked to View.onScrollChanged() and it is called when scrolling happened, but I can't determine when scrolling animation ends. 我迷上了View.onScrollChanged(),它在滚动发生时被调用,但是我无法确定滚动动画何时结束。

In theory there should be a way to say that fling movement is over. 从理论上讲,应该有一种说法说猛攻运动已经结束。 Is there such API? 有没有这样的API?

我没有找到跟踪滚动动画的方法,但是可以将滚动逻辑从Horizo​​ntalScrollView类移到由您派生的类,您可以在其中控制滚动的各个方面

I'm replying to a post a year old but this might be useful for future readers. 我要回复一岁的帖子,但这可能对将来的读者有用。

For implementing HOME-Like scroll, use Gallery instead of HorizontalScrollView . 要实现类似HOME的滚动,请使用Gallery而不是HorizontalScrollView Using 'Gallery' you need not worry about stopping scrolling at predefined positions and it gives you a handler for Fling-gesture too. 使用“图库”,您不必担心在预定位置停止滚动,它也为您提供了Fling-gesture的处理程序。 Add your code in onFling() or onScroll() as per your requirement. 根据需要将代码添加到onFling()onScroll()中。

More info @ http://developer.android.com/reference/android/widget/Gallery.html 更多信息@ http://developer.android.com/reference/android/widget/Gallery.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM