Android: Understanding when ScrollView has reached the bottom

(May 12th, 2010)

This snippet is pretty mutch as the title says, an example in detecting when ScrollView has reached the bottom. In this sample I extend ScrollView and then overrides the onScrollChanged method (inherited from View).

protected void onScrollChanged(int l, int t, int oldl, int oldt)
        // Grab the last child placed in the ScrollView, we need it to determinate the bottom position.
        View view = (View) getChildAt(getChildCount()-1);
        // Calculate the scrolldiff
        int diff = (view.getBottom()-(getHeight()+getScrollY()));
        // if diff is zero, then the bottom has been reached
        if( diff == 0 )
                // notify that we have reached the bottom
                Log.d(ScrollTest.LOG_TAG, "MyScrollView: Bottom has been reached" );

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

Cheers to this thread for helping me getting the calculations right.

You can find a full implementation here:

7 Responses to “Android: Understanding when ScrollView has reached the bottom”

  1. Danilo Graciano says:

    Thank you! This code works fine.

  2. Thank you so much !! exactly what i needed !!

  3. Hi thats very nice tutorial on scrollview concept in android you can also check the one at
    android scrollview

    android styled scrollview

  4. Màrius Garcia says:

    it rocks !!!

  5. Tony says:

    Thank you, it works!
    But don’t forget about paddings.

  6. Ricardo says:

    Hi! Do you have a full implementation of this code? Thanks in advance!

  7. admin says:

    Hi Ricardo!
    I have updated the post with a link to a class I use.
    / M

Leave a Reply