我只想检测嵌套滚动视图NestedScrollView Android在底部的位置,然后调用函数。 我的代码是:
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");
}
}
});
但是总高度与最大滚动Y不同。如何修复?
ViewCompat.canScrollVertically(View v, int direction)
。 - Nikola Despotoski