Android Recycleview 翻页效果(类似ViewPager)
原文链接:https://www.zybuluo.com/whosea/note/1006457
compile 'com.github.whosea:GravitySnapRecycleView:1.0.0'
项目应用效果:
demo效果:
创建处理翻页效果类(另外总共支持start end top bottom 和 center 五种行为):
GravitySnapHelper snapHelper = new GravitySnapHelper(Gravity.CENTER);
snapHelper.setColumn(3);//如果一页里面有超过1列的都需要设置
snapHelper.attachToRecyclerView(recyclerview);
snapHelper.setCanPageScroll(true);//是否启用一页一页的滚动,默认不启用
翻页监听
PageIndicatorHelper pageIndicatorHelper = new PageIndicatorHelper();
pageIndicatorHelper.setPageColumn(column);
pageIndicatorHelper.setRecyclerView(rvCenter);
pageIndicatorHelper.setOnPageChangeListener(new GravityPageChangeListener() {
@Override
public void onPageSelected(int position,int currentPage,int totalPage) {
Log.e("MainActivity",currentPage+ "/"+totalPage);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});