How to detect how much the view has scroll ScrollView

自闭症网瘾萝莉.ら 提交于 2019-12-23 12:55:54

问题


How can i detect how much a scroll view has scrolled ?


回答1:


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.



来源:https://stackoverflow.com/questions/12543495/how-to-detect-how-much-the-view-has-scroll-scrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!