4

How can i detect how much a scroll view has scrolled ?

Bunny Rabbit
  • 7,957
  • 15
  • 62
  • 103

1 Answers1

2

You need to override the onScrollChanged() method of the ScrollView:

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {

    Log.i(TAG, "View onScrollChanged");
    View view = (View) getChildAt(getChildCount() - 1);
    int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate

    super.onScrollChanged(l, t, oldl, oldt);
}

Here, diff is the space left for scrolling between the bottom edge of the ScrollView, and the currently visible content at the bottom. When diff = 0, the ScrollView has been scrolled down fully.

Raghav Sood
  • 80,914
  • 21
  • 183
  • 190