Hi! I have a scrollable Column and some button at ...
# compose
d
Hi! I have a scrollable Column and some button at the bottom which animates the size of another composable above it (
animateContentSize
) when clicked. The other composable pushes the button down and out of the view. Is there a way to set some anchor or something to the Column or the
verticalScroll
-modifier? I've tried to
animateScrollBy
some amount as the content size changes but I'm not happy with the result..
1
s
Can you try BringIntoViewRequester on the button and see if that feels any better? And potentially wait until the top item is expanded and then do the movement animation perhaps. Other than that I'm not sure what you can do
d
Ok, thanks, I will check out the BringIntoViewRequester 👀
Cool, that worked surprisingly well! Thanks!
s
Nice! Did you have to delay asking to bring into view, or did you do it exactly at the same time as you asked for the item above to expand?
d
I delayed it for 1000ms for now, if not it would be too many movements happing at the same time. Are you familiar with the API? I'm looking into the
rect
parameter, but I'm not sure if I'm using it correctly. Do you know what they mean by "local coordinates" in the
rect
param description in the docs? Can I get the rect they're asking for from
onGloballyPositioned
?
s
No I haven’t actually used this API before, I just know that it exists. I’d guess this https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]eIntoViewSample&ss=androidx%2Fplatform%2Fframeworks%2Fsupport is your best bet to see how to properly use it.
d
Yeaah, I saw that one, but they use hard coded values.. Anyways, I'll play around with it and see if I figure something out, thanks for pointing me in this direction! 🎉
🎉 1
s
Do let me know if you make it work properly for you, I’d also be interested to see how to “properly” use this api 😊
d
Will do! ☺️ 👍
(just to elaborate on what I'm trying to achieve:
bringIntoView()
(without a providing a rect, referencing a composable instead) works as expected, it scrolls so that the composable is in the view. However, in my case, I want it to scroll a bit further due to some overlapping view that sticks to the bottom of the screen, so I'm looking for a way to scroll an additional amount without it looking weird (I could do it with an additional call to scroll on scrollState but that wouldn't look good). Will keep you updated.)
s
Put an empty component below your button, exactly at the point where you want to scroll to, and ask that one to be brought into view 😅 Sounds silly but it might just work 🤷‍♂️
☺️ 1