Using Android SDK Classes
So far, we've seen how to create our own animations, using time-based animations or using a fixed time step mechanism. But Android provides us several ways of doing animations using its SDK and the animation framework. In most cases, we can simplify our animations by just using the property animator system instead of creating our own, but that will depend, always, on the complexity of what we want to achieve and how we want to tackle the development.
For more information please refer to the property animation framework from the Android developer's documentation website.
ValueAnimator
As part of the property animator system, we have the ValueAnimator
class. We can use it to simply animate int
, float
, or color
variables or properties. It's quite easy to use, for instance we can animate a float value from 0
to 360
during 1500
milliseconds using the following code:
ValueAnimator angleAnimator = ValueAnimator.ofFloat(0, 360.f); angleAnimator.setDuration(1500); angleAnimator...