https://kotlinlang.org logo
#compose
Title
# compose
r

Rafal

04/20/2022, 12:23 PM
I want to slowly migrate to Jetpack Compose view by view and I have a horizontal
RecyclerView
in my
NavigationView
. When I use the
LazyRow
or
Row(Modifier.horizontalScroll())
the touch events are not intercepted properly and instead of scrolling the row, the
NavigationView
is closing. Is there any way to make the
ComposeView
intercept touch events?
a

Adam Powell

04/20/2022, 1:42 PM
This is probably a better question for #android at this point since it's heavily related to Android View touch handling. cc @matvei
You're likely looking to have your UI participate in Android's nested scrolling, or at a minimum,
requestDisallowInterceptTouchEvent
from the parent. It's not that your child view isn't intercepting, parents intercept. You want to prevent the parent container from intercepting the touch interaction
("intercept" has a very specific meaning in android touch handling)
m

matvei

04/20/2022, 3:15 PM
I feel like having a sample or a bit more info about the hierarchy would help to understand the problem more. Without that, I'm making an assumption and expect you to have a DrawerLayout with your NavigationView? If so, how did you handle this before? I suspect (as Adam suggested) that some manual disallowance handling was involved in this case as DrawerLayout doesn't support nested scrolling. In this case, similar handling should work in your case as well, only you have to disallow and allow the parent scrolling at the compose-specific event times.
r

Rafal

04/20/2022, 3:16 PM
I'll try to cook up a sample when I get back home
haha ok turns out my friend already did some touch intercept magic around the
RecyclerView
so it seemed to be working out of the box, applying same code to the
ComposeView
solves the issue
👍 1
4 Views