Simplifying View Animation with ViewPropertyAnimator
What if you're animating many properties of a view object? Well, in Android 3.1, a new class was added to the Android SDK: the ViewPropertyAnimator class (android.view.ViewPropertyAnimator). Along with this addition, the View class also received a new method called animate() that returns a ViewPropertyAnimator object. That's rightall View objects have an internal animator class now. Not only does this simplify animation of multiple properties, but it also allows the internal system to access the properties directly rather than by using reflection to make method calls on commonly used controls, which enhances performance.
Here's an example of how you might use the animate() function with a Button control variable called button:
This code snippet sets the animation duration to 1200ms, the target transparency to 50%, and the x value to animate to 250, and then starts the animation.