In previous versions of android3.0, to implement animations, it was common to use the Nineoldandroid Open source framework, after which you could use the animation API provided by Android directly.
After a closer look at this open-source framework, you can see that there is a difference between this framework and the system's animation implementation. Major but not just a few points:
1. Calculate the flow of each frame animation: Animationhandler,nineoldandroid is inherited from the handler, in the message queue constantly processing the data of each frame animation, and the system is implemented runnable interface, processing in the thread
1 //nineoldandroid2 Private Static classAnimationhandlerextendshandler{3 Public voidHandlermessage () {4 ....5 sendemptymessagedelayed (...);6 }7 8 9 //Android SystemTen protected Static classAnimationhandlerImplementsRunnable { One //The per-thread list of all active animations A /**@hide*/ - protected FinalArraylist<valueanimator> manimations =NewArraylist<valueanimator>(); - the //used in Doanimationframe () to avoid concurrent modifications of manimations - Private FinalArraylist<valueanimator> mtmpanimations =NewArraylist<valueanimator>(); - - //The per-thread set of animations to being started on the next animation frame + /**@hide*/ - protected FinalArraylist<valueanimator> mpendinganimations =NewArraylist<valueanimator>(); + A /** at * Internal Per-thread collections used to avoid set collisions as animations start and end - * While being processed. - * @hide - */ - protected FinalArraylist<valueanimator> mdelayedanims =NewArraylist<valueanimator>(); - Private FinalArraylist<valueanimator> mendinganims =NewArraylist<valueanimator>(); in Private FinalArraylist<valueanimator> mreadyanims =NewArraylist<valueanimator>(); - to Private Finalchoreographer Mchoreographer; + ..... -}View Code
2. Choreographer: Unlike the open source framework, the Android system also introduces the choreographer (choreographer), which coordinates animation time, drawing, and so on. The main thing is that the vsync is provided in the choreographer: Vertical interrupt.
Choreographer coordinates each frame of time, using a callback function to execute the Runnable.run. Can make the animation display smoother, no animation lag, picture tearing and other conditions. Some of the more specific knowledge about VSync can be Baidu.
Android Open source framework: nineoldandroid