获取Recyclerview滑动的是哪个Item

2017-01-22  本文已影响0人  Taurus_z

获取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);
            }
        });
上一篇 下一篇

猜你喜欢

热点阅读