Reputation: 3645
Basically what the title says. I am trying to implement my own fastscroller.
recyclerView.scrollToPosition(position);
System.out.println(position + " :: " +
linearLayoutManager.findFirstVisibleItemPosition() );
Now the problem is that these two values do not match sometimes and I do not know why. This means, that the recyclerview does not scroll to the desired position and linearLayoutManager is correct about the current position.
The outputs are strange, the first visible position either matches the desired scroll position or the first visible position is below exactly 7 positions further than desired. (Except when recyclerview needs some time scroll to the position.)
Outputs:
I/System.out: 49 :: 42
I/System.out: 82 :: 42
I/System.out: 82 :: 75
...
I/System.out: 386 :: 379
I/System.out: 431 :: 379
I/System.out: 431 :: 424
I/System.out: 431 :: 424
So how can I scroll exactly to the desired position?
Edit: I realized I do not need to scroll recyclerview, but the LinearLayoutManager...
linearLayoutManager.scrollToPositionWithOffset(position, 0);
Upvotes: 0
Views: 649
Reputation: 185
afaik the recyclerview scrolls as far as the desired position shows up at the bottom of the screen.
llm.findFirstVisiblePosition()
shows the first item on the screen == the one on the top of the screen.
Upvotes: 1