title: Android RecyclerView with gradient background
body: <p>Is it possible to set the background of a recyclerview to a gradient so that the gradient spans the whole recyclerview rather than spanning the screen? In other words I want the background drawable height to be equal to the total height of all items, so that the background color changes when user scrolls down and that the end color of the gradient can only be reached when the user scrolls down to the last item.</p>
  <pre><code>&lt;shape&gt;
      &lt;gradient
          android:startColor=&quot;@color/colorPrimary500&quot;
          android:endColor=&quot;@color/colorSecondary50&quot;
          android:angle=&quot;90&quot;/&gt;
  &lt;/shape&gt;
  </code></pre>
  <p>When I use this shape as the background of a recyclerview with <code>height=&quot;wrap_content&quot;</code>, I can scroll down but the gradient spans the screen height and it is static, the end color (yellow) is always at the bottom of the screen and the start color (blue) is always at the top:
  <a href="https://i.stack.imgur.com/jYp6W.jpg" rel="nofollow noreferrer">screenshot</a></p>
  <p>One solution that I thought was setting the height of the recyclerview to the total height of its children but I don't know how it can be done.</p>