【发布时间】:2017-08-22 20:05:33
【问题描述】:
我正在使用无限滚动的循环视图,其中包含重复的 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);
【问题讨论】:
-
你找到这个问题的答案了吗?
标签: android android-recyclerview horizontal-scrolling linearlayoutmanager