美文网首页
获取Recyclerview滑动的是哪个Item

获取Recyclerview滑动的是哪个Item

作者: Taurus_z | 来源:发表于2017-01-22 16:37 被阅读0次

获取Recyclerview滑动的是第几个Item

mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                int firstVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
                Log.i(TAG, "onScrolled: -----------" + firstVisibleItemPosition);
                mLinearLayout.setVisibility(firstVisibleItemPosition == 0 ? View.GONE : View.VISIBLE);
            }
        });

相关文章

网友评论

      本文标题:获取Recyclerview滑动的是哪个Item

      本文链接:https://www.haomeiwen.com/subject/dqjobttx.html