O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—composing a tween animation

In the full Towers of Hanoi game, we don't just put the blocks in one place, but we move them about between different towers. Let's make an animation to describe flipping the block from one place to another.

  1. First up, we need to add a second and third tower, so that our block has somewhere to be moved to. In main.xml, update it, so that it looks like the following:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="bottom|center_horizontal">
    <LinearLayout
    android:id="@+id/tower_1"
    
    android:layout_width="200sp"
    android:background="#FFEEDDDD" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required