Tuesday, 3 November 2009

Android UI and Animations, what's new?

Over the last few days I've been looking at what's new for User interfaces and animations in the latest two releases of Android. Of course there have been some big changes such as the addition of gesture recognition and multi-touch, but i wanted to take a look at some of changes that have been less well publicised, but are still well worth knowing about. Here's some of the things that I found:

Android 1.6
For Android 1.6 here are some of the UI and Animation updates.

In Android 1.6 we've had a whole new set of Interpolators. Remember, Interpolators control animations. Each animation has it's own interpolator. A linear Interpolator means that the animation would be displayed at a constant rate for the animation duration, while and Accelerate Interpolator would mean that the animation would accelerate (get faster) towards the end of its animation duration. The new Interpolators are can all be found in android.view.animation and they are:

  • AnticipateInterpolator: An interpolator where the change starts backward then flings forward.
  • AnticipateOvershootInterpolator: An interpolator where the change starts backward then flings forward and overshoots the target value and finally goes back to the final value.
  • BounceInterpolator: An interpolator where the change bounces at the end.
  • OvershootInterpolator: An interpolator where the change flings forward and overshoots the last value then comes back.

For me these are an interesting addition to the animations for the android frame work. Taken together they can be used to create animations with a springy, bouncy and elastic feel, which you'll be very familiar with if you've ever used an iphone. ;)

Here's an example of using the OvershootInterpolator when applied to the ViewFlipper slide animation shown in a previous post:

Notice the slight overshoot at the end of the animation...

On click listeners
Another interesting addition to the UI framework in Android 1.6 is the ability to define click listeners in you XML layout file like this:
<Button android:onClick="myClickHandler" />

Now all you need is a public myClickHandler function that takes a View as an argument:
class MyActivity extends Activity {
public void myClickHandler(View target)
{ // Do stuff }
This gives the programmer a much more concise way of declaring and implementing click listeners.

For more info' on the changes to the UI framework in Android 1.6 see the post here.

Android 2.0 UI changes
For Android 2.0 we have:

New system themes
New system themes in android.R.style to easily display activities on top of the current system wallpaper. The new themes available are:

WallpaperManager API
New WallpaperManager API replaces and extends the wallpaper APIs that were previously in Context, to allow applications to request and set the system wallpaper. Here there a two new methods in Animation called setDetachWallpaper and getDetachWallpaper. By setting Detached wallpaper to true an animation will only be applied to the window, and the wallpaper behind it will remain static.

Key Event Dispatching
KeyEvent has new key dispatching APIs, to help implement action-on-up and long press behavior, as well a new mechanism to cancel key presses (for virtual keys).

One last interesting thing on UI and Animations for Android 2.0. I've heard rumours that there is a "new exciting graphics technology" that is being worked on. I couldn't see any real evidence of this on the current android 2.0 release, but I read on blogs that there is another minor update due before the end of the year. So who knows, maybe this new graphics technology will be part of that minor release. If I find anything I will of course write about it and let others know.


Post a Comment