Timed frame animations

We have already used this kind of animation on the 3D example in our previous chapter. The main concept consists of assigning a new value to all the animatable properties before drawing a new frame based on the amount of time passed. We can be tempted with incrementing or computing a new value based on the number of frames drawn, but that is highly inadvisable, as the animation will be played at different speeds depending on the speed of the device, computation, or drawing complexity and other processes executing in the background.

To do it right, we have to involve something independent from the rendering speed, frames per second, or frames drawn, and a perfect solution is to use time-based animations.

Android provides ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.