I'm developing a search contact feature, in that screen, there is a RecyclerView inside NestedScrolView (fillViewport = true).
Screen design: (This design is accepted by customer, I can't change it)
After loading all contacts of current device into an ArrayList, the search results are filtered from this array.
There is several cases that make the app very laggy:
1. When user type an input that have no result, then user clear search, I have to show all results again. The NestedScrollView has to render UI for all items of RecyclerView (for example: 300 items).
2. When the quantity of results has many changes (for example, from 1 to 300 items). The NestedScrollView has to render UI for a lot of items of RecyclerView
I know this design breaks recycling technique of RecyclerView, but I can't change it.
What I tried:
?
In AndroidManifest:
recyclerView.setNestedScrollingEnabled(false);
The adapter:
android:windowSoftInputMode="adjustNothing"
答案 0 :(得分:7)
您正在使用RecyclerView错误。而不是将您的RecyclerView放在NestedScrollView中,而是将您的" Header"和"搜索框"在RecyclerView内部作为不同的视图类型。
这个answer就是一个很好的例子。