'Setting the scrollState when listing a lazyColumn

To draw data using the paging and jetpack composite libraries, I use the LazyColumn(). The data comes in every second and I need to stop the view on the elements when I go down. Now they go lower when adding fresh data at the top of the list. How i can do it with scrollState or any other method?

@Composable
fun HistoryTableList(
    viewModel: HistoryViewModel = viewModel()
) {
    val scrollState = rememberLazyListState()
    val coroutineScope = rememberCoroutineScope()

    LazyColumn(
        state = scrollState,
        modifier = Modifier
            .padding(
                HistoryListHorizontalPadding,
                0.dp,
                HistoryListHorizontalPadding,
                HistoryListPaddingBottom
            )
            .fillMaxWidth(),
    ) {
        items(historyItems) { historyRecord ->
            if (historyRecord != null) {
                // need to set scrollState to view elements without moving[![enter image description here][1]][1]
                HistoryTableItem(history = historyRecord)
            }
        }
    }
}

Now they move if I go down

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source