https://kotlinlang.org logo
#compose
Title
# compose
z

zt

07/26/2022, 3:32 AM
I'm using a LazyColumn to display a list of videos but it loses its scroll position when navigating away from it to another screen. If i remove the loading indicator item then it remembers the scroll position properly
Copy code
LazyColumn(
        modifier = Modifier
            .fillMaxSize()
            .padding(horizontal = 14.dp),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.spacedBy(8.dp)
    ) {
        items(videoListItems) { video ->
            if (video == null) return@items

            VideoCard(
                video = video,
                onClick = { onClickVideo(video.id) },
                onClickChannel = { onClickChannel(video.author!!.id) }
            )
        }

        item {
            videoListItems.loadState.apply {
                when (append) {
                    is LoadState.Loading -> {
                        CircularProgressIndicator(modifier = Modifier.padding(4.dp))
                    }
                    is LoadState.Error -> {
                        (append as LoadState.Error).error.printStackTrace()

                        Text("An error has occurred")
                    }
                    else -> Unit
                }
            }
        }
    }
i

Ian Lake

07/26/2022, 3:44 PM
z

zt

10/14/2022, 6:30 AM
Still no proper solution to this problem?
@Ian Lake
4 Views