Android Animation categories and differences

Source: Internet
Author: User


Android contains three kinds of animations: View Animation, drawable Animation, property Animation (newly introduced Android3.0).

View Animation:

With the view-based gradient animation, she only changes the view's drawing effect, and the actual property value does not change. For example, the animation moves a button position, but the actual position of the button click remains unchanged. You can refer to the subclasses of the Animationset class and animation if you define animations in your code, and you can define an XML file in the res/anim/folder if you use XML.

Drawable Animation:

Load a series of drawable resources to create animations, a traditional animation that, in part, creates different sequences of images, which are played sequentially, just like film footage. Define animation frames in code, use the Animationdrawable class, XML files make it easier to compose animation frames, and in the Res/drawable folder, use <animation-list> <item> to define different frames. The feeling can only be set is the animation interval time.

Property Animation:

Animation objects, in addition to traditional view objects, can also be object objects, after the animation, the property values of object objects are actually changed. Property animation can implement view animations by changing the actual properties of the View object. Any time the View property is changed, view can automatically call invalidate () to try the refresh.

New properties when the view implements property animation:

    • Translationx, Translationy: The change value of the upper left coordinate
    • Rotation, RotationX, RotationY
    • ScaleX, ScaleY: horizontal longitudinal scale, such as: 1.2f, 0.8f
    • Pivotx, Pivoty: The Horizontal vertical center point of scale and rotation, which by default is the center of the view, should be set to 0 if you want to rotate or scale in the center of the top left coordinate of the view.
    • X, Y:
    • Alpha: transparency. Default is 1, 0 for full transparency, i.e. invisible

Example:objectanimator.offloat (MyView, "rotation", 0f, 270f);

These properties correspond to the view properties in the layout file, and differ:Pivotx and Pivoty correspond to Android:transformpivotx and Android:transformpivotx In addition ScaleX and ScaleY: Scaling is based on the original size, such as enlarged twice times after, want to reduce twice times, that is, revert to their own size, if the use of Viewpropertyanimator code should be as follows:

    • Myview.animate (). ScaleX (2.0f). ScaleY (2.0f)//expand twice times
    • Myview.animate (). ScaleX (1.0f). ScaleY (1.0f)//restore

Starting with Android 3.1, the XML file definition for property animation is located in res/animator/(not res/anim/). The corresponding XML tags in the property animation class are as follows:

    • Valueanimator-<animator>
    • Objectanimator-<objectAnimator>
    • Animatorset-<set>

Android Animation categories and differences

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.