简体   繁体   中英

Android: How to detect end of scroll

I need to implement HorizontalScrollView which is scrolled to predefined positions (similar to Home behaviour). 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.

In theory there should be a way to say that fling movement is over. Is there such 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 . Using 'Gallery' you need not worry about stopping scrolling at predefined positions and it gives you a handler for Fling-gesture too. Add your code in onFling() or onScroll() as per your requirement.

More info @ http://developer.android.com/reference/android/widget/Gallery.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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