Capture onScroll event in Android ScrollView

narkis picture narkis · Feb 5, 2014 · Viewed 9k times · Source

Simple scenario - ScrollView hosting a single LinearLayout which has several children - the preferred pattern to allow a scroll enabled views in developing on Android.

I need to capture onScrollEvents, start, stop, etc. that are readily available and work very well if I use ListView/onScrollListener combination.

A dedicated widget for scrolling a view DOES NOT have the built-in capabilities to capture these events? Come On! I have tried OnTouchEvent listener, onGestureListener, etc - all work arounds and all meant for something else. What am I missing here?

Answer

FD_ picture FD_ · Feb 5, 2014

Unfortunately, there is no pre-built way for getting these events. However, there are two workarounds:

  • Use a ListView instead

  • Build your own custom ScrollView with ScrollListener. This is not that hard to achieve and has been done before.