[英]How to detect how much the view has scroll ScrollView
如何检测滚动视图滚动了多少?
You need to override the onScrollChanged()
method of the ScrollView: 您需要重写ScrollView的
onScrollChanged()
方法:
@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. 在这里,
diff
是ScrollView
底部边缘与底部当前可见内容之间滚动的剩余空间。 When diff = 0
, the ScrollView
has been scrolled down fully. 当
diff = 0
, ScrollView
已完全向下滚动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.