Sunday, February 8, 2009

Parallax Scrolling in Android

A while ago I heard about something called parallax scrolling [1] being used on Google's Android platform (specifically on the G1). I had just gotten the G1 at that point and hadn't noticed that it was doing something special when scrolling between the three screens in the "home" application.

The idea is pretty simple, you have two surfaces that scroll at two different speeds, one is bigger or father away, depending on how you look at it.

On the G1 it allows the background of the home screen to be smaller than the total "viewable area" that the three home screens cover. This is useful since the size of the home screen areas can change drastically when the phone is flipped open. It also creates the illusion of depth.

Below is my implementation using Proce55ing (click and drag the light purple square).

This browser does not have a Java Plug-in. Get the latest Java Plug-in here.

Source code: parallax (plain text)

1 - Turns out I was probably reading a Qt developer blog. These posts support that conclusion.

No comments:

Post a Comment