as arguments.
Per default it scrolls the list so that the item is the first one.
If a positive
scrollOffset
is given it scrolls further, making the item go off scren.
So I tried to give a negative
scrollOffset
and calculate what I need so that the element is in center position.
The problem is: Negative Offsets are not allowed. 😞
How can I scroll to an index that it's at the center of the list?
without that the only way I can think of doing it is if your items are all the same size so you could scroll the appropriate other item to the top of the view - hacky I know
s
Stefan Oltmann
09/17/2021, 6:21 AM
Thank you for pointing me to the feature request.
Unfortunately they are not all the same size.
Nevertheless I need to hack that I guess.
Stefan Oltmann
09/17/2021, 7:10 AM
@John Nichol In SwiftUI you can provide an
anchor
like
leading
,
center
and
trailing
to the
scrollTo
function and it works out-of-the-box. I wish I had the same with Jetpack Compose.
Stefan Oltmann
09/20/2021, 9:13 AM
@John Nichol I wasn't successful to find a reliable relatively quick hack. This looks like a lot of work to me to do that in a proper way.
I created an issue for the Jetpack Compose team and we will see if they manage to match functionality with SwiftUI here.
https://issuetracker.google.com/issues/200374702