I have a Scrollview which contains an ImageView and RecyclerView. if navigation drawer opened then closed the RecyclerView auto scrolling to top, How to stop this?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollViewMain"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView_main_icons_line"
android:src="@drawable/main_line" />
...
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_activity_main_passenger_log"
android:paddingBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
This problem because of recyclerView has default focus.
Solution
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
Add android:descendantFocusability="blocksDescendants"
to your immediate layout of scrollView