我有一个水平RecyclerView 和两个按钮(下一页,previous),如下图所示。
I have a horizontal RecyclerView and two button (Next,Previous) as shown in the image below.
所以我需要通过使用移动到下一个项目或位置的这些按钮,我知道调用的方法 scrollTo ,但我不知道它是如何工作
so i need to move to the next item or position by use these buttons , i know about method called scrollTo but i don't know how does it work
推荐答案RecyclerViews 有其暴露滚动到一定位置的方法:
RecyclerViews have a methods which they expose for scrolling to a certain position:
捕捉滚动到指定位置:
mRecyclerView.scrollToPosition(int position)平滑滚动到指定位置:
mRecyclerView.smoothScrollToPosition(int position)有关这些方法的工作,的LayoutManager 的需要已实施这些方法的 RecyclerView 和 LinearLayoutManager 在做一个基本的方式实现这些,所以你应该是好去。
For these methods to work, the LayoutManager of the RecyclerView needs to have implemented these methods, and LinearLayoutManager does implement these in a basic manner, so you should be good to go.
更多推荐
如何以编程方式滚动水平RecyclerView?
发布评论