Open MiguelRossi opened 4 years ago
Apparently how topChild
is retrieved in onDrawOver()
has something to do with it.
can you provide example or movie/gif?
Here a .gif
:
I found that in this piece of code:
val topChild = parent.findChildViewUnder(
parent.paddingLeft.toFloat(),
parent.paddingTop.toFloat()
) ?: return
there is nothing under parent.paddingLeft.toFloat()
because the items in the list have margin.
When I delete all the margins the headers stick perfectly:
When I delete lateral the margins headers blink:
I've done a quick fix as a suggestion. Instead of:
val topChild = parent.findChildViewUnder(
parent.paddingLeft.toFloat(),
parent.paddingTop.toFloat()
) ?: return
this:
val currentTopChild = parent.findChildViewUnder(
parent.width.toFloat() / 2,
parent.paddingTop.toFloat()
)
val nextTopChild = parent.findChildViewUnder(
parent.width.toFloat() / 2,
parent.paddingTop.toFloat() + distanceBetweenItems
)
val topChild = currentTopChild ?: nextTopChild ?: return
getDistanceBetweenItems(topChild, parent)
parent.width.toFloat() / 2
: it's more accurate to expect the list item to reach the centre of the RecyclerView than a side (you know: size, padding, margin, ...)
nextTopChild
: in case there is a gap between items just at the top of the parent, it finds the next item on the list.
Tried the library today (v0.8.1 and v0.8.2), and the headers disappear just after a small scrolling.