# Advanced Pre-Honeycomb Animation with NineOldAndroids

DevFeed: [Advanced Pre-Honeycomb Animation with NineOldAndroids](<https://devfeed.tech/articles/advanced-pre-honeycomb-animation-with-nineoldandroids-20914.md>)

Original publisher: [Read original article](<https://jakewharton.com/advanced-pre-honeycomb-animation/>)

Published: 2012-01-18T00:00:00Z

Content type: tutorial

Language: en

Sources: [Jake Wharton](<https://devfeed.tech/sources/jake-wharton.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Library](<https://devfeed.tech/topics/library.md>), [Canvas](<https://devfeed.tech/topics/canvas.md>), [Framework](<https://devfeed.tech/topics/framework.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [animation](<https://devfeed.tech/tags/animation.md>), [api](<https://devfeed.tech/tags/api.md>), [library](<https://devfeed.tech/tags/library.md>), [rotation](<https://devfeed.tech/tags/rotation.md>), [scale](<https://devfeed.tech/tags/scale.md>), [ui](<https://devfeed.tech/tags/ui.md>)

## AI overview

This article explains how to support Android Honeycomb-style view transformations on pre-Honeycomb platforms using NineOldAndroids. It describes using view animation callbacks, a Transformation object, alpha, matrices, and canvas rendering to implement translation, scaling, rotation, and other properties through a lightweight custom animation class.

## Source excerpt

The lovely new animation framework in Android 3.0 came with some additional methods on the View class to allow for transformations such as translation, scale, rotation, and alpha. The NineOldAndroids library allows for the use of this API on any platform but is limited only to modifying values for which methods exist on the running platform. Recently I set out to solve this problem and allow for utilizing my library to animate these properties regardless of the API level. Neither an answer to the linked StackOverflow question nor a quick exchange with the animation guru Chet Haase himself semed to produce a reliable, stable implementation for this--the recommendation always being to just use the built-in view animation. As I was digging around in the View class I noticed that there really was no way to achieve this effect directly, even with reflection. It was only once I started poking around how view animations are processed and executed did a rather clever solution appear to me. For those that are not familiar with how the view animation framework works, an animation receives a callback with a Transformation object and a time interval. Each animation then adjusts the object in order to reflect the state of the associated view at whatever time interval it is at. Since the Transformation object contains a method for setting alpha and a matrix which is applied to the canvas rendering the view we can easily achieve all of the transformations of the native methods introduced in Honeycomb. void applyTransformation(float interpolatedTime, Transformation t) { //Perform transformations } So now that we know these transformations were possible, how best to implement them in a manner that can be used by the new animation API? To accomplish this we use a few tricks of view animation in order to do this in a way that is as lightweight and fast as possible (we're on the UI thread, remember). Only one animation can be applied to a view at a time so it was obvious that a custom