In this post, we will see how to resolve Idomatic way of using animateDpAsState in padding jetpack compose
Question:
I am learning animateDpAsState from the doc. I did it without any problem, but I see a lot of recomposing happens. So I want to know what is the recommended way of doing this?
Best Answer:
Instead of animating the top padding, you can do something different applying a y-translation with thegraphicsLayer
modifier with the lambda block that causes the layer properties update without triggering recomposition and relayout.You can apply it to the
Column
or to each children.Something like:
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com