如何检测滚动视图滚动了多少?
You need to override the onScrollChanged()
method of the ScrollView:
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
Log.i(TAG, "View onScrollChanged");
View view = (View) getChildAt(getChildCount() - 1);
int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate
super.onScrollChanged(l, t, oldl, oldt);
}
Here, diff
is the space left for scrolling between the bottom edge of the ScrollView
, and the currently visible content at the bottom. When diff = 0
, the ScrollView
has been scrolled down fully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.