'Android RecyclerView with gradient background
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.
<shape>
<gradient
android:startColor="@color/colorPrimary500"
android:endColor="@color/colorSecondary50"
android:angle="90"/>
</shape>
When I use this shape as the background of a recyclerview with height="wrap_content", 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:
screenshot
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
