获取listview滚动的距离

来源:互联网 发布:亚盛医药 知乎 编辑:程序博客网 时间:2024/05/17 20:31
    public int getScrollY(AbsListView mListView) {
        View c = mListView.getChildAt(0);
        if (c == null ) {
            return 0;
        }
        int firstVisiblePosition = mListView.getFirstVisiblePosition();
        int top = c.getTop();
        return -top + firstVisiblePosition * c.getHeight() ;
   }
1 0