Does Jetpack Compose have the tools to create custom OverscrollEffect?

Viewed 619

Is there a way to create OverscrollEffect in jetpack compose?

Something like this:

enter image description here

1 Answers

The overscroll effect can be controlled by the LocalOverscrollConfiguration, which currently has the following parameters:

glowColor - color for the glow effect, if the platform effect is a glow effect, otherwise ignored.
forceShowAlways - force show overscroll even if content doesn't scroll (is smaller than a scrollable container itself)
drawPadding - the amount of padding to apply from scrollable container bounds to effect before drawing it

CompositionLocalProvider(
    LocalOverscrollConfiguration provides OverScrollConfiguration(
        glowColor = Color.Gray,
        forceShowAlways = false,
        drawPadding = PaddingValues()
    )
) {
    // effected views
}

If you think there should be more parameters, you can let the maintainers know by creating a feature request.


p.s. in 1.2.0-rc01 LocalOverScrollConfiguration has being renamed to LocalOverscrollConfiguration

Related