2

I have a normal XML view with a LinearLayout inside a NestedScrollView. Inside there is a normal View and a Composable view which contains an AndroidView.

The layout:

<NestedScrollView ...>
    <LinearLayout ...>
       <View .../> <!-- click listener works properly -->
       <androidx.compose.ui.platform.ComposeView .../> <!-- click in inner AndroidView doesn't work properly -->
    </LinearLayout>
</NestedScrollView>

The ComposeView is set like this:

composeView.setContent {
    AndroidView(factory = {
        TextView(it).apply {
            setText("View in Compose")
            setOnClickListener { } // This breaks the scroll
        }
    })
}

When tapping the View inside a Compose the scroll doesn't work. The click listener eats all touch events.

Is there any way to make Android View click inside Compose behave correctly?

juissi
  • 91
  • 6
  • I am sorry, I mistake the scroll view class. I used the NestedScrollView. It is reported that Compose & View interoperability is not yet supported with it: https://developer.android.com/jetpack/compose/interop/compose-in-existing-ui – juissi Nov 19 '21 at 10:38
  • 1
    Chris banes has posted a workaround in the issue tracker, I answered to a related issue here: https://stackoverflow.com/a/70195667/1128600 – Steffen Funke Dec 02 '21 at 07:41

1 Answers1

-1

Usually there is a Boolean exposed called as requireUnconsumed in all such cases. I'm not really sure about the particular implementation since it concerns interop, not something that I might wanna get into, I'd say just read the docs. Seriously, you'll find it there.

Richard Onslow Roper
  • 5,477
  • 2
  • 11
  • 42