How do you set the maximum value for a manually-controlled scroll? I can’t set the
maxValue
on
ScrollState
because it’s internal… I’m using
verticalScroll
modifier on my component, but can’t figure out how to set its limits…
orangy
04/11/2021, 8:02 PM
@Adam Powell sorry for mention, but I’m asking this for a second time already I think and have no idea how to progress…
a
Adam Powell
04/11/2021, 8:14 PM
@matvei for next week
m
matvei
04/12/2021, 10:32 AM
Hm, could you share what are you trying to achieve? Modifiers like
Modifier.verticalScroll
or
Modifier.horizontalScroll
are autonomous in this regard as they will measure your @Composable you are applying them to and get the max height from it. Hence
state.maxHeight
is a read only val. So the bounds are the natural 0 and height of a composable, assuming the composable is bigger then its viewport.
If you want something more custom and want to have more control over the scroll and how to interpret it, you could try using
Modifier.scrollable
, which provides scroll handling but not layout, allowing you to write more custom things
o
orangy
04/16/2021, 1:39 PM
@matvei It’s a SnakeLayout component, which is kinda like grid (fixed size cells), but odd and even rows are in opposite directions 🙂 It’s basically a
Layout
with
verticalScroll
, and pretty trivial placing. I’ll send gist in DM.
, which is essentially “infinite” vertically. I had to rewrite the component’s logic to first calculate item placements, then infer maxHeight from there, and then call layout with proper height.