Categories
android android-nestedscrollview

how to detect the position of the scroll nestedscrollview android at the bottom?

i just want to detect the position of the scroll nestedscrollview android at the bottom, and the to call function.
my code is :

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");
}
}
});

but totalheight not same wit MAX ScrollY. how to fix it ?