It works on component activity, but not on composeview() from fragment that hosted by appcompatactivity()
I’m working with Jetpack Compose and have a LazyColumn where the last item contains clickable fields. When I click clickable item like text or icon button on the screen clickable fields clicked at first time, the column scrolls slightly upwards, causing the item to move out of view. This behavior is problematic as it affects user experience, particularly when interacting with the last item in the list.
Details:
I use LazyColumn to display a list of items. Each item in the list has clickable fields or checkboxes. When the clickable fields clicked at first time, it causes the LazyColumn to scroll slightly up, which is undesirable as it hides the item from view.
Used LazyListState to manage the scroll position and attempted to programmatically scroll to the last item using animateScrollToItem(). Despite these efforts, the issue of the LazyColumn scrolling up slightly when the clickable fields clicked at first time is clicked persists.
here is the code,
@Composable
fun DummyScreen() {
val state= rememberLazyListState()
AppTheme {
Scaffold { contentPadding ->
LazyColumn(
state = state,
modifier = Modifier.padding(contentPadding)
) {
items(3) { index ->
Card(
modifier = Modifier
.fillMaxWidth()
.height(320.dp)
.padding(8.dp)
.background(Color.Red)
) {
Text(text = "item ${index}",
modifier = Modifier.clickable {
//TO DO SOME THING
}
)
}
}
}
}
}
}
lazyListState
inLazyColumn
to maintain state