B
B
BitNeBolt2020-11-14 22:09:22
Android
BitNeBolt, 2020-11-14 22:09:22

Why does RecyclerView keep its scroll position when the screen is rotated?

There is data for the list, stored in LiveData in the ViewModel. The activity receives data from there and sets it to the adapter (and when creating the adapter, an empty list is passed to it).

The scroll position of the list remains the same as it was at the beginning, although I did nothing specifically for this.

Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-11-15
@BitNeBolt

Because the recycler, like any normal view, can save its state. The layout manager has special methods for this even.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question