2. Animation
The Android framework provides two
animation systems:
property animation (introduced in Android
3.0)
view animation. (using XML)
Both animation systems are viable
options, but the property animation
system, in general, is the preferred
method to use, because it is more flexible
and offers more features.
3. Property Animation
Introduced in Android 3.0 (API level 11)
lets you animate properties of any object,
including ones that are not rendered to
the screen.
The system is extensible and lets you
animate properties of custom types as
well.
4. Property Animation
Is a robust framework that allows you to
animate almost anything.
You can define an animation to change
any object property over time, regardless
of whether it draws to the screen or not.
it’s changes a property's (a field in an
object) value over a specified length of
time.
5. Property Animation
characteristics
Duration (The default length is 300 ms)
Time interpolation (function of the animation’s)
Repeat count and behavior
Animator sets (You can group animations into
logical sets that play together or sequentially or
after specified delays)
Frame refresh delay (The default is set to
refresh every 10 ms)
6. Animator
The Animator class provides the basic
structure for creating animations.
You normally do not use this class directly
as it only provides minimal functionality
that must be extended to fully support
animating values.
7. Subclasses of Animator used
ValueAnimator
This class provides a simple timing engine for running animations which
calculate animated values and set them on target objects.
ObjectAnimator
This subclass of ValueAnimator provides support for animating
properties on target objects.
The constructors of this class take parameters to define the target
object that will be animated as well as the name of the property that
will be animated.
it makes the process of animating values on target objects much
easier
ObjectAnimator has a few more restrictions(Use ValueAnimator).
AnimatorSet
Provides a mechanism to group animations together so that they run
in relation to one another.
You can set animations to play together, sequentially, or after a
specified delay
8. Animating with ValueAnimator
ValueAnimator animation= ValueAnimator.ofFloat(0f, 1f);
animation.setDuration(2000);
animation.addUpdateListener(new
ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator
animation) {
Float value = (Float)
animation.getAnimatedValue();
Float frac =
animation.getAnimatedFraction();
textView.setAlpha(value);}
});
10. AnimatorSet
AnimatorSet set1= new AnimatorSet();
Play()
Before()
With()
After()
Note : you can play set into another set
AnimatorSet set2= new AnimatorSet();
Set2.paly(set1).before(anim);