首页 > 其他 > 详细

判断RecyclerView是否滑动到底部

时间:2019-07-15 19:15:27      阅读:680      评论:0      收藏:0      [点我收藏+]

判断RecyclerView是否滑动到底部


recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
     public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                View lastChildView = recyclerView.getLayoutManager().getChildAt(recyclerView.getLayoutManager().getChildCount() -1);
                int lastChildBottom = lastChildView.getBottom();
                int recyclerBottom = recyclerView.getBottom() - recyclerView.getPaddingBottom();
                int lastPosition = recyclerView.getLayoutManager().getPosition(lastChildView);

                if (lastChildBottom == recyclerBottom && lastPosition == recyclerView.getLayoutManager().getItemCount() - 1) {
                    //滑动到底部
                    // do something...
                }

            }
        });

判断RecyclerView是否滑动到底部

原文:https://www.cnblogs.com/Ricardoldc/p/11190692.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!