基于RecycleView编写的左右滑动ViewPager,与其他ViewPager不同的是,第一个和最后一个item靠边放大,其他的中间放大。
1、RecyclerView使用HouseScaleLayoutManager
HouseScaleLayoutManager layoutManager = new HouseScaleLayoutManager
.Builder(this, 0)
.build();
layoutManager.setOrientation(CardScaleLayoutManager.HORIZONTAL);
layoutManager.setInfinite(false);
recyclerView.setLayoutManager(layoutManager);
2、滑动绑定,使用HouseBannerSnapHelper绑定RecyclerView
HouseBannerSnapHelper pagerSnapHelper = new HouseBannerSnapHelper();
pagerSnapHelper.attachToRecyclerView(recyclerView);
3、绑定Adapter,自定义View的样式
HouseBannerSnapHelper pagerSnapHelper = new HouseBannerSnapHelper();
pagerSnapHelper.attachToRecyclerView(recyclerView);
maven引入方式:
<dependency>
<groupId>com.alzzz</groupId>
<artifactId>scalemanagerlib</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
gradle引入方式:
implementation 'com.alzzz:scalemanagerlib:1.0.0'