Android sample app that implements a scratch-to-reveal card in Jetpack Compose: the user drags on a top “foil” layer; an image underneath appears through the scratched path. When enough of the visible area is covered, the overlay can fade out (“vanish”).
Screen_recording_20260413_183916.mp4
ScratchOverlay— Composable that stacks optional revealed content under scratchable content, handles drag gestures, draws the erase stroke withBlendMode.Clearon an offscreen layer, and runs the vanish animation.ScratchState— Holds the scratch polyline, grid-based coverage (no GPU pixel readback), optional clip via AndroidRegion, and reveal flags.ScratchOverlayConfig/ScratchAreaSpec— Brush width, vanish threshold, animation duration, optionalclipShape, and sizing (match scratchable vs fixedDpSize).
- Android Studio / Gradle as in the project wrappers
- minSdk / compileSdk as defined in
app/build.gradle.kts
./gradlew :app:installDebugOr open the project in Android Studio and run the app configuration.
Apache 2.0