简单实现RecyclerView版本的竖向翻页效果

1实现子页面撑满父布局,这样页面就只能显示一个个页面了
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
子布局
android:layout_width="match_parent"
android:layout_height="match_parent"
类似于这种长宽都和父亲一样大

2 设置每次滑动滑动页面底部
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);

3监听页面加载到下一个页面
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
LinearLayoutManager manager = (LinearLayoutManager) recyclerView1.getLayoutManager();
int first = manager.findFirstVisibleItemPosition();
if (first != last) {
last = first;
Toast.makeText(MainActivity.this, "" + first, Toast.LENGTH_SHORT).show();
}

        }
    });

参考项目:

你可能感兴趣的:(简单实现RecyclerView版本的竖向翻页效果)