When using the jetpack compose interoperability API, using LazyRow inside a prebuilt ViewPager causes scroll issues.
When trying to scroll items inside the LazyRow the ViewPager moves. Is there any way we can prevent this?
ComposeView
<androidx.compose.ui.platform.ComposeView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Setting the view in the fragment
binding.composeView.setContent {
HorizontalScrollableView(listOfCards)
}
And the view written in compose
@Composable
fun HorizontalScrollableView(listOfCards: List<Cards>) {
Column(
modifier = Modifier
.background(color = colorResource(R.color.grey10))
) {
Text(
text = "Items",
color = colors.primary,
style = typography.subheadBold,
fontSize = 15.sp,
modifier = Modifier.padding(start = 16.dp, top = 10.dp, end = 16.dp)
)
LazyRow(contentPadding = PaddingValues(end = 16.dp)) {
items(
items = listOfCards,
key = { listOfCards.id }
) {
RenderCard(it)
}
}
}
}
Pager
and usingAndroidView
s (orAndroidViewBinding
s) for traditional views. – Vu