ValueAnimation of Android property animation and android property Animation
ValueAnimation is the parent class of the ObjectAnimation class. I believe you have some knowledge of ObjectAnimation. Today I will give you a brief introduction to ValueAnimation, valueAnimation Google provides better process control. Now we will give you a brief introduction to a small animation with time-based settings:
The layout file of the application is very simple. There is only one Button, so we will not go into details. The following describes the specific implementation:
Public void init () {button = (Button) findViewById (R. id. fourbutton); button. setOnClickListener (new myButtonListener ();} public class myButtonListener implements View. onClickListener {@ Override public void onClick (View view) {final ValueAnimator animator = ValueAnimator. ofInt (1,100); animator. setDuration (5000); animator. setInterpolator (new LinearInterpolator (); // The linear effect changes to animator. addUpdateListener (new ValueAnimator. animatorUpdateListener () {@ Override public void onAnimationUpdate (ValueAnimator valueAnimator) {Integer integer = (Integer) animator. getAnimatedValue (); button. setText ("" + integer) ;}}); animator. start ();}}
The above is all the code of the small application. The focus is on The Implementation of The addUpdateListener () method by rewriting ValueAnimator. the onAnimationUpdate (ValueAnimator valueAnimator) method of AnimatorUpdateListener () controls the entire animation implementation process.
Now we have finished introducing the implementation of property animation for Android.
1. common attributes:
TranslationX/translationY: horizontal | vertical offset
Rotation/rotationX/rotationY: 3D flip
ScaleX/scaleY: X axis | scaling of the Y axis
X/Y: the specific point to be moved.
Alpha: Transparency
These five attributes of property animation are similar to the four attributes of the previous value animation. However, the execution efficiency of the property animation framework is higher and the effect is better.
2. Common methods and classes:
ValueAnimation and ObjectAnimation classes: for these two classes, I believe you are no stranger. For more functions, please query Google API
AnimationUpdateListener and AnimationListenerAdapter: Listener events used for property Animation
PopertyValuesHolder: controls the display effect, sequence, and flow control of an animation set.
AnimationSet, TypeEvaluators: Value calculator and difference Calculator
Interpolator: animation display variation pattern
3. Attributes of Interpolator:
AccelerateInterpolator: continuous acceleration
DecelerateInterpolator: constant slowdown
AnticipateInterpolator: convex
OvershootInterpolator: tail up
LinearInterpolator: linear variation
BounceInterpolator: Free-body
The above are the six attributes of the Interpolator calculator. you can experiment with them in the project to better understand and use them.
To today's Android property animation summary for everyone to complete, welcome to exchange learning (1453296946@qq.com ).