How can I detect TOP from ScrollView? I have implemented code to determine the bottom, but I can’t understand that the calculation determines when the top was reached.
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
int startPosition = t;
View view = (View) getChildAt(getChildCount() - 1);
int diff = (view.getBottom() - (getHeight() + getScrollY()));
if (diff == startPosition){
oListener.onTopReached();
} else {
nListener.BottomNotReached();
}
super.onScrollChanged(l, t, oldl, oldt);
}
source
share