RecyclerView steals focus when inside a NestedScrollView
using android:descendantFocusability="blocksDescendants" very dangerous. Because it blocks opening keyboard. For example at the same page you use edittext and you solve the problem using blocksDescendants. and you click the edittext, keyboard will not open. For this reason, you should use android:focusableInTouchMode="true" in root view in NestedScrollView.
For me accepted answer didn't work. I solve this by adding this attribute for parent:
android:descendantFocusability="blocksDescendants"
Thanks @Amagi82. You answer helped me but it was not enough. I added more 2 attributes. That worked for me:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:focusable="true"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:id="@+id/someView"
android:layout_width="wrap_content"
android:layout_height="350dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Make your top view focusable. "RecyclerView has "focusableOnTouchMode" set to true to handle its childrens' focus changes during layout." Relevant discussion of the issue.
Example:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical">
<View
android:id="@+id/someView"
android:layout_width="wrap_content"
android:layout_height="350dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>