直接上代码吧
如果你APP的API适配的minSdkVersion高于21,直接在RecyclerView中加上android:nestedScrollingEnabled="false"
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:nestedScrollingEnabled="false" /> </android.support.v4.widget.NestedScrollView>
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this); mLayoutManager.setSmoothScrollbarEnabled(true); mLayoutManager.setAutoMeasureEnabled(true); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setHasFixedSize(true); mRecyclerView.setNestedScrollingEnabled(false);