Adding Android support to Trident

November 27th, 2009

The main goal of Trident project is to provide a general purpose animation library for Java applications. Animations are a natural fit for modern client applications, and Trident has special built-in support for Java based UI toolkits such as Swing and SWT. The latest 1.2dev drop of Trident provides first support for Android, Google’s software stack for mobile devices.

First, a video that illustrates Trident looping timeline that animates the foreground color of an Android button running in an emulator:

And here is the code of the main activity behind this screen:

public void onCreate(Bundle savedInstanceState) {
	Button button = new Button(this);
	button.setText("Hello, Android");

	Timeline timeline = new Timeline();
	timeline.addPropertyToInterpolate(Timeline. property(

Those of you who are familiar with the Trident APIs can see that it is the same exact approach as with Swing and SWT. The only difference for Android is the explicit usage of the color interpolator, since the Android APIs use integers for colors – and the built-in mechanism for auto-discovering the matching property interpolator cannot handle this case without explicit coding in either the app code or future Android code base.

Apart from the explicit usage of property interpolator, the application code does not need to handle the UI threading issues (making sure that the TextView.setTextColor is called on the matching UI thread).

If you’re interesting in using Trident in your Android apps, take the latest Trident 1.2dev (code named Cookie Jar) and add it to your Android project. The project documentation describes the basic terminology of Trident, and will provide more Android-specific examples in the next few weeks.