Make AndroidView propagate touch events to underlying Composable

Viewed 588

Having the following layout, is it possible to make Button (or any other views under AndroidView) receive touch events even though the AndroidView overlays the whole screen? I was able to make it work with two Composables or two old-fashioned Views, but not with a Composable and a View.

@Composable
fun SomeScreen() {
    Box(
        contentAlignment = Alignment.Center,
        modifier = Modifier.fillMaxSize()
    ) {
        Button(
            onClick = {}
        ) {
            Text(text = "Button")
        }
        AndroidView(
            viewBlock = {
                View(it).apply {
                    setBackgroundResource(android.R.color.transparent)
                    layoutParams = ViewGroup.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT
                    )
                }
            }
        )
    }
}
0 Answers
Related