如何使用RecyclerView调用jumpTo(targetPosition)

问题描述:

void jumpTo (int targetPosition) 
Instead of specifying pixels to scroll, use the target position to jump using scrollToPosition(int). 

You may prefer using this method if scroll target is really far away and you prefer to jump to a location and smooth scroll afterwards. 

Note that calling this method takes priority over other update methods such as update(int, int, int, Interpolator), setX(float), setY(float) and #setInterpolator(Interpolator). If you call jumpTo(int), the other changes will not be considered for this animation frame. 

我正在寻找一种方法来从RecyclerView调用“jumpTo(targetPosition)”。 目前我使用的是“LinearLayoutManager.scrollToPositionWithOffset(position,offset)”,但当位置在屏幕上不可见时并不总是执行。如何使用RecyclerView调用jumpTo(targetPosition)

例如。 - LISTSIZE = 100 - 当前在屏幕/可见光19,20,21,22,23 - scrollToPositionWithOffset(30,0)// FAIL - scrollToPositionWithOffset(22,0)// SUCCESS

呼叫的方法RecyclerView.scrollToPosition(int position)

mRecyclerView.scrollToPosition(position) // whatever your index is.