这是我的适配器
我想每次滚动时滚动一项。就像你在 Instagram 上看到多张图片一样。我该怎么做?
谢谢
_vimrc
和我的 XML;
recyclerViewyeterr=findViewById(R.id.recyclerViewyeterr);
LinearLayoutManager horizontalLayoutManagaer = new LinearLayoutManager(GYUserSahaDetay.this,
LinearLayoutManager.HORIZONTAL, false);
recyclerViewyeterr.setLayoutManager(horizontalLayoutManagaer);
gYresimadaptor=new GYresimadaptor(resimler2);
recyclerViewyeterr.setAdapter(gYresimadaptor);
答案 0 :(得分:1)
您可以通过使用 SnapHalper.attachToRecyclerView()
将 SnapHelper 附加到您的 RecyclerView 来使用它,并且您将获得类似于 Instagram 的滚动效果,例如:
recyclerViewyeterr=findViewById(R.id.recyclerViewyeterr);
LinearLayoutManager horizontalLayoutManagaer = new LinearLayoutManager(GYUserSahaDetay.this,
LinearLayoutManager.HORIZONTAL, false);
recyclerViewyeterr.setLayoutManager(horizontalLayoutManagaer);
gYresimadaptor=new GYresimadaptor(resimler2);
recyclerViewyeterr.setAdapter(gYresimadaptor);
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerViewyeterr);
答案 1 :(得分:1)
据了解,你想制作这个 对于像 instagram 这样超过 1 张照片帖子或历史记录的房车,您必须使用此布局管理器代码,并且必须设计全宽卡片视图。
这是通用的解决方案
rv.setLayoutManager(new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.HORIZONTAL));