3

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.

  1. The RecyclerView is used along with the BottomSheetBehavior. With a height of 0dp the sheet cannot be opened!
  2. The height of the custom views is known to be half the view width.
  3. 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?

l33t
  • 18,692
  • 16
  • 103
  • 180

0 Answers0