AndroidView inside ComposeView: touch dispatch order between View and Compose pointer input
0 reputation · 27 Mar 2025, 02:44 UTC
Integration boundary
I am designing a screen where a legacy View hierarchy (containing its own touch handling, e.g. a custom map or drawing surface) is embedded in Jetpack Compose via AndroidView, and the surrounding Compose tree also uses pointerInput modifiers for gestures.
Goal and constraints
The goal is predictable, deterministic touch dispatch: I need to know which side sees a touch event first, and under what conditions the embedded View can consume events before Compose's PointerInputModifier chain runs (and vice versa). Documentation indicates the View system dispatches events first and ComposeView feeds them into Compose's pointer input, but the ordering relative to child Views is not clearly guaranteed, and behavior may vary across Android API levels 21–34. Targeting Compose BOM 2024.x with Kotlin 2.0.x and a matching Compose compiler plugin.
Open questions
- Is the dispatch order between an
AndroidView'sonTouchEventand a parent ComposepointerInputmodifier contractually defined, or implementation-dependent per API level? - What is the supported mechanism for an embedded View to reliably claim or yield a gesture stream at the boundary?
- Is logging touch coordinates on both sides of a minimal repro an accepted way to verify ordering, or is there a documented test hook?