Created
February 24, 2022 04:19
-
-
Save theapache64/275553a0fa320227693dc4998b13dab0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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