Draw scrollbar over RecyclerView.ItemDecoration sticky header

109 Views Asked by At

I am extending RecyclerView.ItemDecoration to define a class that enables a RecyclerView to make header view's sticky when they are at the top of the RecyclerView. For this, I need to override onDrawOver() to draw the sticky header , since I need to draw the sticky header on top of all the other RecyclerView view's. This has the unfortunate side effect of also drawing the sticky header on top of the RecyclerView's scrollbar. I am wondering if there is some way I can easily get the RecyclerView to draw it's scrollbar over this sticky header?

I've tried doing the following already:

  • Mess around with android:scrollbarStyle XML tag on RecyclerView. Setting this to outsideOverlay does not draw the scrollbar over the sticky header.
  • Move sticky header drawing logic to onDraw() instead of onDrawOver(). Doing this draws the sticky header underneath the scrollbar, but also draws it underneath the RecyclerView's other views.

Any feedback is helpful. Thanks.

0

There are 0 best solutions below