ValueAnimation of Android property animation and android property Animation

Source: Internet
Author: User

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 ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.