como detectar a posição do scroll nestedscrollview android na parte inferior?

Eu só quero detectar a posição do scroll nestedscrollview android na parte inferior e a função de chamada. meu código é:

scroll.getViewTreeObserver()
      .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
           @Override
           public void onScrollChanged() {
               int totalHeight = scroll.getChildAt(0).getHeight();
               int scrollY = scroll.getScrollY();
               Log.v("position", "totalHeight=" + totalHeight + "scrollY=" + scrollY);
               if (scrollY==totalHeight) {
                   getPlaylistFromServer("more");
               }
           }
      });

mas totalheight não é o mesmo com MAX ScrollY. como corrigi-lo ?

questionAnswers(3)

yourAnswerToTheQuestion