is it possible to have a button that is pinned to the bottom of the screen (either via box alignment...
a
is it possible to have a button that is pinned to the bottom of the screen (either via box alignment or Column arrangement) when the content is not scrollable, but switch to scrolling along witht he rest of the content when there is enough content to scroll?
This example is for LazyList but you can also use it with a
Column
and
verticalScroll
modifier.
a
awesome, exactly what i was looking for thank you
s
I’ve done this by simply having my screen be a column with fillmaxsize, and having a
Spacer(Modifier.weight(1f)
right above that button like here. If there is no scrolling happening, the spacer will take up as much space as it can and it will push what’s below further down. If there’s enough content to make the column scrollable, then weight(1f) has no effect and everything scrolls together. I hope I did understand your problem correctly
a
oh thats nice! really good to know, def sounds like it would work for me too. i think i prefer the explicit custom arrangement in this instance but i will have to remember that
s
I’d find the arrangements tricky to use, as adding another item would mean you’d also have to change the arrengement. In my case for example, I have 5 items that need to be bottom attached like this. 2 “real” items, and 2 spacers in-between, but also one at the bottom which is supposed to add the spacing behind the navigation bar, basically the bottom insets. Doing this in an arrangement would mean if I remove something it’d act weird again and it becomes a game of being off by 1 index here and there. The weight(1f) just works at least as far as I’ve tried. Just giving you my perspective, use whatever you wish of course 😄
c
TIL that the Spacer with
weight(1f)
has no effect if there is scroll happening. This definitely makes more sense for a plain Column (the custom arrangement is still useful for lazy lists and such).
707 Views