title: How to make RecyclerView do recycling inside NestedScrollView?
body: <p>I tried to put several views, including <code>RecyclerView</code>, into a <code>NestedScrollView</code>. I used <code>setNestedScrollingEnabled(false)</code> and it looked nice for small data sets but started to be laggy for bigger ones.</p>
  
  <p>After spending some time on logging the <code>onCreateViewHolder()</code> method I understood that the recycler view creates them all at once as the old <code>ListView</code>. I tried to find reasons of such behavior in <code>RecyclerView</code> docs, but I found it in <code>ScrollView</code> <a href="https://developer.android.com/reference/android/widget/ScrollView.html" rel="noreferrer">description</a>:</p>
  
  <blockquote>
    <p>You should never use a ScrollView with a ListView, because ListView
    takes care of its own vertical scrolling. Most importantly, doing this
    defeats all of the important optimizations in ListView for dealing
    with large lists, since it effectively forces the ListView to display
    its entire list of items to fill up the infinite container supplied by
    ScrollView.</p>
  </blockquote>
  
  <p>I hoped that <code>NestedScrollView</code> would solve the issue but it appears that it hadn't.</p>
  
  <p>Are there any ways, for example, using some custom <code>LayoutManager</code> to use <code>RecyclerView</code> with its optimizations of view recycling?</p>
  
  <p>P.s. Of course, I know about method <code>getItemViewType(int pos)</code> and possibility to add custom headers and footers using this technique but it looks like an ugly workaround for me. And yes, I am using it at the moment, because it is better to have code that is harder to maintain than such big performance issue.</p>