I have a fragment_layout.xml with two buttons (filter_1_btn, filter_2_btn) that perform filtering to the items of a RecyclerView. The problem is that when I scroll a bit (because the TextView above the buttons contains multiple lines of text) and then apply the filtering, then the NestedScrollView scrolls on top of the screen. Is there a way to stay at the same scrolled height after the filtering?
fragment_layout
<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/nested_scrollView" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantFocusability="blocksDescendants" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical"> <TextView android:id="@+id/description_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="36dp" android:text="Very long random text..." /> <Button android:id="@+id/filter_1_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Filter 1"/> <Button android:id="@+id/filter_2_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Filter 2"/> <androidx.recyclerview.widget.RecyclerView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="24dp" /> </LinearLayout> </androidx.core.widget.NestedScrollView>