❖Details of each System
❖Android provides variety of APIs to animate UI elements and create
custom 2D and 3D graphics.
❖The presentation details about the available techniques to create
different animations using different systems provided by android.
Android provides the following 3 different animation systems.
❖Introduced in Android 3.0 version.
❖Allows to animate property of any object including the one which is not
visible to the user.
❖Allows to animate on custom types as well.
How it works?
❖Modifies the property value of an object over a specified period of time.
❖Property of an object is nothing but the field in an object.
❖To animate, specify the below things.
❖what property value you want to change over a time. Ex: object’s position
❖duration of the animation
❖range of values
Property animation system lets you define the following things.
➢ Duration of the animation.
❖ Time Interpolation
➢ How the property value should be changed over the time. Its a fn of time.
❖ Repeat Count and behavior
➢ whether to repeat the animation or not and also the behavior of the animation.
❖ Animator Sets
In the above example, consider ‘x’ is the property of the object.
observe the value of ‘x’ changes over the period of 40ms.
interpolator determines the value of ‘x’ based on linear or nonlinear fn of time.
Hence it plays very important role for creating any animation.
❖ValueAnimator object keeps track of your animation's timing, such as how long
the animation has been running, and the current value of the property that it is
❖The ValueAnimator encapsulates TimeInterpolator and TypeEvaluator.
❖TimeInterpolator which defines the interpolation of the animation.
Android supports many implementations of TimeInterpolator.
➢ Ex: AccelerateInterpolator
❖TypeEvaluator which defines how to calculate the property value of the
animation. Android provides many implementations TypeEvaluators.
➢ Ex: IntEvaluator
❖ValueAnimator, TimeInterpolator and TypeEvaluator work hand in hand to
complete the animation.
➢ Sub class of ValueAnimator which allows to set target object and object’s property to
➢ Makes the process of animating values of target objects much easier.
➢ Sometimes you may have to use ValueAnimator due some restriction on the
objectAnimator where some of the property access methods are not accessible/missing.
➢ Animations can be grouped and played related to each other.
➢ Animations can be played sequentially, after a delay between each animation.
❖Can be used to perform the tweened animation on the views.
❖A tween animation can perform series of
transformations(position,size,rotation and transparency) on the content of
the view object. Ex: if you have a textview, you can move,rotate, shrink and
grow the size.
❖Animation can be defined either in XML file or in code. XML file is more
readable and reusable.
❖Animation instructions defines the transformation you want to occur,
animation duration, when to occur.
❖Lets you load a series of drawable resources to create an animation.
❖Traditional style of creating an animation where series of images played
like film roll.
❖AnimationDrawable is the main class to define animation through code.
❖Animation can be created using XML file as well.
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
Property Animation vs View Animation
❖View Animation only allows
➢ to animate view objects. Non-view objects can not animated using this system.
➢ Only few aspects of the view can be animated like size, rotation, transparency.
➢ Original object of the view will not be changed.
❖ Using Property Animation all the above limitation can be removed as it is
❖However, View Animation system takes less setup time and required less
code to be written.
References and Resources
❖For defining animation in an XML file. Refer
❖Refer API Demo Sample(animation package) for examples.