运行截图
基于 PagerSnapHelper 自定义 GridPagerSnapHelper.
支持横向与纵向滑动,行列数量可自定义传入
private void initGridePager() {
// 3行3列,横向
int colum = 3;
int row = 3;
int orientation = GridLayoutManager.HORIZONTAL;
int spanCount = (GridLayoutManager.VERTICAL == orientation) ? colum : row;
// 设置布局管理器
GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), spanCount, orientation, false);
mRecyclerView.setLayoutManager(gridLayoutManager);
// 设置设配器
GridPagerAdapter gridPagerAdapter