NestedScrollView或ScrollView與RecyclerView嵌套使用導致adapter滑動卡頓
直接進入正題
我們在項目中經常性使用NestedScrollView或ScrollView與RecyclerView嵌套的佈局,但我們在運行後發現總會出現各種各樣的問題,如adapter的item顯示不全問題,請點擊這裏;滑動卡頓等等。
解決辦法
直接在RecyclerView中添加android:nestedScrollingEnabled=“false”,把adapter的滑動交給外層的NestedScrollView或ScrollView,這樣就能完美的解決滑動卡頓問題了。
<android.support.v7.widget.RecyclerView
android:id="@+id/rlv_shangou"
android:nestedScrollingEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>