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)”但是当屏幕上看不到位置时,并不总是执行它。
例如。 - listSize = 100 - 目前在屏幕上/可见19,20,21,22,23 - scrollToPositionWithOffset(30,0)// FAIL - scrollToPositionWithOffset(22,0)// SUCCESS
答案 0 :(得分:0)
RecyclerView.scrollToPosition(int position)的调用方法
mRecyclerView.scrollToPosition(position) // whatever your index is.