I have 4 classes (2 Activities and 2 ViewModels) which are called MainActivity, FavouritesActivity. PLUS MainViewModel, FavouritesViewModel which extends AndroidViewModel. All things with FavouriteAvtivity and FavouriteViewModel works perfectly fine. Meanwhile, the other two are implemented the same way but when I rotate the device my List's scroll position resets, and I have literally tried everything I found regarding saving the list state in onSaveInstanceState() and onRestoreInstanceState().
Here's my application repo on GitHub: PopularMovies
I found the issue cause why it's happening for MainActivity only even though implementations are same. The issue is with your layout movie_list_item, you have to specify constant height otherwise layout gets remeasure and list scrolled up on device rotate. to prevent that use the below modified layout.
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/iv_movie_thumbnail"
android:layout_width="184dp"
android:layout_height="180dp" // don't use wrap_content, can use any height you want but make it that fix
android:contentDescription="@string/movie_thumbnail"/>