1

I need to listen to the scroll of a ScrollView. In order to do that I extended the ScrollView overriding its onScrollChanged(int, int, int, int).

When the view scrolls I move another view along with that scroll, and all is ok. When I release the view while scrolling, the ScrollView still scrolls with an inertia effect (smooth scroll). The problem is that, after the release, the method onScrollChanged is called after the view is invalidated, the effect is that my view is moved after a small delay with an ugly effect.

In order to avoid this I could disable the smooth scroll from the ScrollView. But, is there a way for listening for the smooth scroll and continuing moving the view also during the residual scroll?

Massimo
  • 3,436
  • 4
  • 40
  • 68

1 Answers1

1

I didn't test it but it's a different way of getting scroll position change.

scrollView.getViewTreeObserver().addOnScrollChangedListener(listener);

this listener is a simple interface:

public void onScrollChanged(){
    scrollView.getscrollY(); // value is here
}
Budius
  • 39,391
  • 16
  • 102
  • 144
  • I found that overriding ScrollView's onScrollChanged was a better solution, but both these two solutions do not solve my problem... thanks – Massimo Apr 29 '15 at 13:03