What is the current, new alternative to ViewAnimator?
I assume what Romain Guy means, is that ViewAnimator
uses Animation
API, whereas a newer API is considered Animator
. See "How Property Animation Differs from View Animation" in the docs, where advantages and disadvantages of each APIs are mentioned as well as usage scenarios:
The view animation system provides the capability to only animate View objects, so if you wanted to animate non-View objects, you have to implement your own code to do so. The view animation system is also constrained in the fact that it only exposes a few aspects of a View object to animate, such as the scaling and rotation of a View but not the background color, for instance.
Another disadvantage of the view animation system is that it only modified where the View was drawn, and not the actual View itself. For instance, if you animated a button to move across the screen, the button draws correctly, but the actual location where you can click the button does not change, so you have to implement your own logic to handle this.
With the property animation system, these constraints are completely removed, and you can animate any property of any object (Views and non-Views) and the object itself is actually modified. The property animation system is also more robust in the way it carries out animation. At a high level, you assign animators to the properties that you want to animate, such as color, position, or size and can define aspects of the animation such as interpolation and synchronization of multiple animators.
The view animation system, however, takes less time to setup and requires less code to write. If view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system. It also might make sense to use both animation systems for different situations if the use case arises.
There is no straightforward way to "convert ViewAnimator
to use newer approach" though, because it internally uses Animation
API. As mentioned in the docs: "if view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system", that's why ViewAnimator
is not deprecated.