I have a Wear OS Overlay built with Compose, that uses a ScalingLazyColumn
and rememberScalingLazyListState()
for scrolling. When the user leaves the overlay and returns I want the column to scroll to the top instead of saving their location. Is there a way to do this?
The screen uses LiveData
/State
so elements recompose while the user is on the screen, and I do not want to lose their scroll position in this case.
@Composable
fun WearApp(weatherVM: WeatherViewModel, application: Application) {
WearAppTheme {
val weather = weatherVM.weather.observeAsState(initial = null)
val listState = rememberScalingLazyListState()
Scaffold(
...
positionIndicator = {
PositionIndicator(
scalingLazyListState = listState
)
}
) {
ScalingLazyColumn(
modifier = Modifier.fillMaxSize(),
autoCentering = AutoCenteringParams(itemIndex = 0),
state = listState
) {
item {
...
}
item {
...
}
...