The implementation principle of Android animation.

Source: Internet
Author: User

1. Animation run mode

Solo mode

Interrupt mode

2.Animation class

Each animation overloads the parent class's Applytransformation method The main function of this method is to assemble some properties into a transformation class, which is called by the Gettransformation method of the parent class. In addition, there is a initialize method for each animation, which completes the initialization work and some preparatory work before the animation begins.

3.Interpolator class

Defines the animation execution process some acceleration deceleration, for our back transformation to serve.

4.Transformation class

Transformation recorded the affine matrix, the animation of each trigger once, the original matrix to do an operation, the view of the bitmap and the matrix can be achieved by the corresponding operation (rotation, translation, scaling, etc.).

The transformation class encapsulates the matrix and alpha values, and it has two important members, one is Mmatrix, the other is Malpha (control transparency).

The process of implementing animations in 5.View

Graphic transformations are implemented through matrices. Graphic transformation is the basic knowledge in graphic science. In simple terms, each transformation is a matrix operation. In Android, the canvas class contains the current matrix, and when the current call to Canvas.drawbitmap (Bm,x,y,paint) is drawn, Android first makes a matrix operation of the BMP and then displays the results of the operation on the canvas. This allows programmers to constantly modify the canvas's matrix and refresh the screen, the View object will continue to do the graphics transformation, animation is formed.

View Create animation object, set animation properties, call invalidate refresh screen, start animation;

The Invalidate method triggers the OnDraw function;

In the OnDraw function:

Call the Gettransformation method of the animation to get the matrix of the current time point

Set the matrix to the current matrix of the canvas

Call the canvas's Drawbitmap method to draw the screen.

Determine the return value of Gettransformation, if true, call the Invalidate method, refresh the screen into the next frame, if False, the animation is complete.

The implementation principle of Android animation.

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.