NestedScrollView或ScrollView與RecyclerView嵌套使用導致adapter滑動卡頓

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"
                    />
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章