Composable Function

rememberNestedScrollInteropConnection

Create and remember the NestedScrollConnection that enables Nested Scroll Interop between a View parent that implements androidx.core.view.NestedScrollingParent3 and a Compose child.

ComposeInCooperatingViewNestedScrollInteropSample

@Composable
fun ComposeInCooperatingViewNestedScrollInteropSample() {
    val nestedSrollInterop = rememberNestedScrollInteropConnection()
    // Add the nested scroll connection to your top level @Composable element
    // using the nestedScroll modifier.
    LazyColumn(modifier = Modifier.nestedScroll(nestedSrollInterop)) {
        items(20) { item ->
            Box(
                modifier =
                    Modifier.padding(16.dp).height(56.dp).fillMaxWidth().background(Color.Gray),
                contentAlignment = Alignment.Center,
            ) {
                Text(item.toString())
            }
        }
    }
}

Last updated: