Disable floating headers when we cannot scroll

If recyclerView content is smaller then the recyclerView, we can already
see all headers.

Change-Id: I1b3b1506236701b75777d97a6fe759b2296f5db0
This commit is contained in:
SpiritCroc 2022-05-25 10:52:14 +02:00
parent 13b4fd9c33
commit 696c9c002f
1 changed files with 4 additions and 0 deletions

View File

@ -52,6 +52,10 @@ abstract class StickyHeaderItemDecoration(
if (parent.childCount == 0) {
return
}
if (!parent.canScrollVertically(1) && !parent.canScrollVertically(-1)) {
// No floating header needs if we cannot scroll, i.e. all headers are already visible
return
}
val topChild = if (reverse) {
parent.getChildAt(parent.childCount - 1) ?: return
} else {