Mehranjp73
Mehranjp73

Reputation: 521

How to set default scroll position for LazyColumn without any feedback or animation in Jetpack Compose

I want my LazyColumn to show items in the list from the middle so I can scroll up or down. I used rememberLazyListState but it has some delay and I don't want the scrolling action to happen in the UI.

Upvotes: 5

Views: 3180

Answers (1)

Jagadeesh K
Jagadeesh K

Reputation: 896

val scrollState = rememberLazyListState(initialFirstVisibleItemIndex = 50)
val scrollState = rememberLazyListState(initialFirstVisibleItemScrollOffset = 3700)

You can use anyone of the parameter to start from a default position if you have 100 items in the list you could set initialFirstVisibleItemIndex = 50 so it starts from middle also you can set the offset but just use any one of them.

It works for me without any delay

Upvotes: 4

Related Questions