ScrollStateHolder
Persists scroll state for nested RecyclerViews.
Call saveScrollState in RecyclerView.Adapter.onViewRecycled to save the scroll position.
Call restoreScrollState in RecyclerView.Adapter.onBindViewHolder after changing the adapter's contents to restore the scroll position
In fragment or activity override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) if (::scrollStateHolder.isInitialized) scrollStateHolder.onSaveInstanceState(outState) }
private lateinit var scrollStateHolder: ScrollStateHolder override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) scrollStateHolder = ScrollStateHolder(savedInstanceState) }
Types
Provides a key that uniquely identifies a RecyclerView
Functions
Restores this RecyclerView layout state for a given key
Saves this RecyclerView layout state for a given key