When I put my RecyclerView inside a NestedScrollView. The LayoutManager and RecyclerView return the same values for getChildCount() and getItemCount() (they are ALWAYS the same, and ALWAYS the max value of the ArrayList/MutableList).
I have a large dataset added to the RecyclerView's custom adapter. Say that it is 400 image thumbnails. getItemCount() should return 400, while getChildCount() should only return like ~20 image thumbnails that a RecyclerView can fit on a screen.
When I use RecyclerView under the NestedScrollView, the getChildCount() always returns 400. I think my RecyclerView is not recycling views like it is supposed to and that I actually have 400 thumbnails displayed at once, instead of 20.
Now, I know I should just use RecyclerView by itself. Most likely, the removal of the NestedScrollView will make RecyclerView work the way it is supposed to. But I need to implement the collapsing toolbar which is typically done with a NestedScrollView with the CoordinatorLayout.
Are there any workarounds to have a RecyclerView with a collapsing toolbar?
My implementation is similar to this.