- Animation and Animator
- Using the Object Animator
- Simplifying View Animation with ViewPropertyAnimator
- Animating Layout Changes
- Conclusion
Animating Layout Changes
There's a certain competing mobile platform that has animations for almost every change made to the equivalent of a layout. Well, a new animator class, LayoutTransition (android.animation.LayoutTransition), enables this ability on the Android platform, too. Layout transitions can be applied to container classes, such as RelativeLayout or any ViewGroup derived object, and applies a default animation to various transitions. The transitions include adding an item, removing an item, and changing the visibility of items. Not only does this apply the animate operation to all of the items directly being changed (e.g., the item you added), but any other view that is moved by the layout change will be animated as well. Enabling this feature can give your user interface transitions a much more fluid and professional appearance. And it's easy to turn on, too. Simply add the following attribute to the XML in your container control in your layout file:
android:animateLayoutChanges="true"
Now as objects come and go from the screen, the layout will smoothly adjust to the changes. Don't like the default animations? You can customize them by manually creating a LayoutTransition object and using the setAnimator() method to specify your own Animator class.