Fragment +NestedScrollView切换时会造成自动滑动的现象

在Fragment中使用NestedScrollView嵌套RecyclerView时,如果来回切换Fragment就可能会造成界面直接滑动到Recyclerview的第一个Item。

解决方案:

在NestedScrollView的第一个父布局中添加如下属性,强制获得焦点

android:descendantFocusability="blocksDescendants"
android:focusable="true"
android:focusableInTouchMode="true"

你可能感兴趣的:(Android,android)