RecyclerView does not Recycling Views when use it inside NestedScrollView

前端 未结 2 1947
一生所求
一生所求 2020-12-08 01:49

I\'m using RecyclerView inside NestedScrollView. Also i set setNestedScrollingEnabled to false for recyclerview

<

相关标签:
2条回答
  • 2020-12-08 02:24

    For a RecyclerView or ListView the height should be constant, because if it will not a constant size then how it will manage the maximum number of visible rows in memory. Try by changing RecyclerView attribute android:layout_height="match_parent" or a fixed height(e.g. "300dp" - as needed), instead of "wrap_content". It should improve your memory management.

    0 讨论(0)
  • 2020-12-08 02:38

    This is because we have a recycler view which has scroll behaviour inside a scroll view. (scroll inside a scroll)

    I think the best way to resolve this issue is to your profileCardview as a header in your recycler view and then remove the nested scroll view.

    If it were a listview then it was as simple as listView.addHeaderView(profileCardView) but for the Recycler view there is no addheadview equivalent. Hence you could refer the below link to change your implementation.

    Is there an addHeaderView equivalent for RecyclerView?

    0 讨论(0)
提交回复
热议问题