【问题标题】:RecyclerView Center Item Larger than others and varying size when scrollingRecyclerView 中心项目比其他项目大,滚动时大小不一
【发布时间】:2020-05-22 11:37:04
【问题描述】:

我想做一个像这样的水平 RecyclerView:(忽略中间的白色圆圈

这里主要的事情是缩放中心项目和缩放传出项目。我可以提供一些参考点来实现这样的观点吗?

【问题讨论】:

标签: android android-recyclerview


【解决方案1】:

你可以使用下面的库,我已经用过这个库了

https://github.com/Azoft/CarouselLayoutManager

添加 CarouselLayoutManager 并如下设置回收站视图属性

CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true);
layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

yourAdapter = new YourAdapter(arrayList, context);
binding.rvGame.setLayoutManager(layoutManager);
binding.rvGame.setHasFixedSize(true);
binding.rvGame.setAdapter(yourAdapter);
binding.rvGame.addOnScrollListener(new CenterScrollListener());

希望对你有帮助!

谢谢。

【讨论】:

  • 这对我不起作用。项目从未出现。我知道为此,RecyclerView 必须是固定大小的,但不知何故没有出现任何项目,我遵循与上述相同的方式。
  • @ParasSidhu 可能是你的代码有问题我已经用同样的方法实现了这个东西,它工作得很好。
  • 抱歉耽搁了,这里是:gist.github.com/sidhuparas/0fa91ce7c02acb8e7c9bd72ad30e01d3 没有项目出现。我尝试使用普通布局管理器并显示项目,所以其他任何东西都不应该有任何问题
猜你喜欢
  • 2021-01-03
  • 2020-01-28
  • 2020-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多