When using AndroidViews I have noticed that while scrolling the view breaks away from the composable it is embedded in and scrolls independently. I have seen this for WebViews, Maps and TextViews, blow is a basic example to show what I'm seeing.
setContent {
val list = mutableListOf<String>()
for (i in 0..100) {
list.add("Text $i")
}
LazyColumn(modifier = Modifier.fillMaxSize()) {
itemsIndexed(list) { _, s ->
Row {
AndroidView(
factory = { context ->
TextView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
text = s
}
},
modifier = Modifier.weight(1f)
)
Icon(imageVector = Icons.Default.ShoppingCart, contentDescription = "CD")
}
}
}
}
If you run it you should see that the composable Icons on the right stay in position and scroll as expected but the TextViews will move away from each other. Is there something obvious I am missing to stop this from happening?
Any help appreciated.