I have a fragment that implements RecyclerView
that I have included in jetpack compose view via AndroidView
. I have pager, one page is in compose and second is in the old style.
Example of whole screen
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(scrollState)
) {
HorizontalPager(
modifier = Modifier
.fillMaxHeight()
.nestedScroll(rememberNestedScroll(scrollState = scrollState)),
count = pages.size,
state = pagerState,
) { page ->
when (val detailPage = pages[page]) {
is oldlayout -> convertToCompose(
modifier = Modifier
.fillMaxSize()
.scrollable(scrollState, Orientation.Vertical)
)
is compose -> ....
}
convertToCompose(modifier: Modifier) {
Box(modifier = modifier) {
AndroidView(
modifier = modifier,
factory = { context ->
......
ViewCompat.setNestedScrollingEnabled(this, true)
}
}
It looks like compose and recyclerview scrolls are not compatible. Compose view scroll works with example of the above. When I'll remove verticalScroll(scrollState)
compose scroll stops working and vica versa, the recyclerview starts working.
Is there any possible way how to forward NestedScroll from compose to old xml layout? I tried it according to official documentation and it didn't help me.
It is recommended to use coordinatorlayout
+ appbarlayout
+ RecycleView
Then Use : RecycleView Item to fill the compose view