TAGS :Viewed: 3 - Published at: a few seconds ago

[ why the interval of invoking applyTransformation() is about 16ms? ]

recently, I am researching the system implement of android.view.animation.Animation.

I override the Animation.applyTransformation() method, and log the invoking interval time, it's about 16ms.

16ms' interval means 60fps. This make the animation plays smoothly.

But why is 16ms? Who control this?

If I implement a animation thread to implement custom animation, I usually do postDelayed(this, 16), so that my Thread will run at 60fps, each time post a message to Handler ,tell it to do some UI change on Main Thread.

How about android system?

Answer 1

I think you are looking for the Choreographer class:

Coordinates the timing of animations, input and drawing. The choreographer receives timing pulses (such as vertical synchronization) from the display subsystem then schedules work to occur as part of rendering the next display frame.