Skip to content

Instantly share code, notes, and snippets.

@theapache64
Created February 24, 2022 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theapache64/275553a0fa320227693dc4998b13dab0 to your computer and use it in GitHub Desktop.
Save theapache64/275553a0fa320227693dc4998b13dab0 to your computer and use it in GitHub Desktop.
Column {
val list = remember { mutableStateListOf<String>("A") }
val listState = rememberLazyListState()
LaunchedEffect(list.size) {
listState.animateScrollToItem(list.lastIndex)
}
Button(onClick = {
list.add(System.currentTimeMillis().toString())
}) {
Text(text = "ADD")
}
LazyColumn(
state = listState
) {
items(list, key = { it }) { item ->
Text(
text = item,
modifier = Modifier
.background(Color.Red)
.padding(50.dp)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment