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.