我正在使用无限滚动的循环器视图,其中包含重复的 X 项。我也想使用PagerSnapHelper()像 viewpager 一样捕捉滚动。
一旦我开始在左右两侧滚动,PageSnapHelper() 就会开始工作,就像 viewpager 一样,中心对齐是这样的 -
我想在最初加载时将 recyclerview 显示为第二张图像。请告诉接下来要做什么来实现这一目标。
这是代码片段 -
linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
this.recyclerView.setLayoutManager(linearLayoutManager);
SnapHelper snapHelper = new PagerSnapHelper();
adapterCarousel = new AdapterCarousel(mContext, glideRequestManager);
adapterCarousel.setViewType(RECYCLER_VIEW_TYPE_NORMAL);
adapterCarousel.setCarousel(carousel);
this.recyclerView.setAdapter(adapterCarousel);
snapHelper.attachToRecyclerView(recyclerView);
linearLayoutManager.scrollToPosition(Integer.MAX_VALUE / 2);