Mix
Mix

Reputation: 31

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?

Upvotes: 1

Views: 2165

Answers (2)

Gagan
Gagan

Reputation: 1497

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

Upvotes: 1

Mix
Mix

Reputation: 31

I did not find a way to track scroll animation, but it's possible to move scroll logic from HorizontalScrollView class to derived by you, where you can control every aspect of scrolling

Upvotes: 2

Related Questions