hey all, I have a doubt about `AndroidView`. Using...
# compose
f
hey all, I have a doubt about
AndroidView
. Using just views a
FrameLayout
above something else it doesn’t intercept any touches, instead using an
AndroidView
on top of a composable all the touches are intercepted
🧵 1
something like this works:
Copy code
<FrameLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Click here!" />

    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#2FFF"/>
</FrameLayout>
Adding a clickListener on text it works (even if there is a
FrameLayout
above it). Doing something similar using Compose all the touches are intercepted by the `AndroidView`:
Copy code
Box(modifier = Modifier.fillMaxSize()) {
    Text(
        modifier = Modifier
            .align(Alignment.Center)
            .clickable { println("Clicked!") },
        text = "Click here!"
    )
    AndroidView(
        factory = {
            FrameLayout(it)
        },
        modifier = Modifier.fillMaxSize()
    )
}
Is this the expected behavior? Is there an easy way to obtain the same behavior we have using just views?
c
I'm on mobile so I can't really try your code, but I wonder if it has anything to do with this bug I filed: https://issuetracker.google.com/issues/185546084
f
yeah, probably it’s something related
a
yes, this might be a bug. it doesn't look like an exact duplicate of 185546084, if you file a separate bug I'll triage it appropriately
does calling
requestDisallowInterceptTouchEvent
in the
update
block fix this for you?
f
hey @Alexandre Elias [G], sorry I didn’t notice your answer 😞
I have tried adding
requestDisallowInterceptTouchEvent
in the
update
block but it doesn’t fix the issue. I have filed a bug here: https://issuetracker.google.com/issues/199918391
thanks in advance for your help!