https://kotlinlang.org logo
i

iex

07/19/2020, 2:04 PM
How to give views an absolute position (want to plot dots on a small graph, for which I'm using
Box
/ shapes)?
ah
Modifier.offset
apparently
a

Adam Powell

07/19/2020, 2:17 PM
If you're just plotting a graph you'll have a far easier time using
Canvas {}
i

iex

07/19/2020, 2:21 PM
I considered it, but is it good for animations (e.g. interpolate between the old and new positions)?
(with small graph I mean max ~100 points, btw)
a

Adam Powell

07/19/2020, 2:43 PM
yes, state reads in a canvas block are observed just like composition and layout, and if that state changes it will be redrawn without needing to recompose to do it.
so animating state values or transition values in a canvas composable are just as effective as they are anywhere else
did something about the shape of the API or docs imply otherwise?
i

iex

07/19/2020, 2:52 PM
ah, no, just assumptions based on unrelated frameworks 😛
I'll give canvas a look then, thanks!
👍 1
a

Adam Powell

07/19/2020, 3:17 PM
If there's some other documentation or emphasis we could add that would have changed those assumptions, please let us know 🙂
2 Views