Using Support library 27.1.1
. I have a NestedScrollView
with BottomSheetBehavior. Inside the bottom sheet layout I have LinearLayout
with a header view at the top, then a RecyclerView
at the bottom. The RecyclerView is populated with 10-20 custom views with heavy onDraw
methods.
The whole idea of having a RecyclerView was to avoid inflating these views, as they are quite heavy to render. I want these views to render as soon as they are scrolled into view (dragging the bottom sheet header). The problem is that all children of the RecyclerView
are inflated/rendered immediately. I thought I could stop this from happening using a custom LinearLayoutManager
but haven't succeeded thus far.
There are a few sources on the net, discussing this particular problem. However, in my case there are a few things that change the conditions.
- The
RecyclerView
is used along with theBottomSheetBehavior
. With a height of0dp
the sheet cannot be opened! - The height of the custom views is known to be half the view width.
- Support Library 27.1.1 or later is targeted (most discussions on the net consider v23.2).
Q: Is it possible to get the RecyclerView
to recycle its views when put inside a NestedScrollView
with BottomSheetBehavior
? Or would it be easier to somehow prevent the heavy onDraw
in the child views?