Horizontal RecylerView look as ViewPager

北慕城南 提交于 2019-12-03 21:42:48

I found solution these two methods make my work easy..

 mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                int pos = ((LinearLayoutManager)(recyclerView.getLayoutManager())).findFirstVisibleItemPosition();
                btnAction(pos,5);
            }
        }); 




private void btnAction(int position, int bannerListSize) {
            for (int i = 0; i < bannerListSize; i++) {
                ImageView imageView = (ImageView) linlay_pager.getChildAt(i);
                if (i == position) {
                    imageView.setImageDrawable(mVectorPagerFillCircle);
                } else {
                    imageView.setImageDrawable(mVectorPagerCircle);
                }
            }
        }

Note: We can use this instead of viewpager specially when we need to show only one item.

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