Mehdi Haghgoo
11/03/2021, 2:42 PMBryan Herbst
11/03/2021, 2:52 PMBryan Herbst
11/03/2021, 2:53 PManimateDpAsState()
that do some of that conversion for us though.Mehdi Haghgoo
11/03/2021, 2:59 PMFelix Schütz
11/03/2021, 4:00 PMLocalDensity.current
to convert between dp and pxFelix Schütz
11/03/2021, 4:01 PMDoris Liu
11/03/2021, 6:53 PMWhy do most animation APIs work pixel-based?I'm assuming this is referring specifically to layout animations. Layout sizes can be defined with
dp
or pixel (for custom layouts). Therefore if we had to pick one unit to support, pixel would be more accurate.
and given the fact that units in Android are often given in d.p, what is the best practice for creating accurate animations?Using
LocalDensity.current
for dp <-> px conversion would be my recommendation as well. 🙂Doris Liu
11/03/2021, 6:59 PManimate*AsState
, Transition.animate*
or Animatable
, Dp
is supported out of the box.