Time for action - animating the display

In order to build a nice slide-out-slide-in animation for the calculator display, we'll need to define our own animations and bind them to a ViewSwitcher object. This will also require us to make changes to the Java code in order to handle the new mechanism. Since we don't want the view to animate each time a new digit is typed, we will make direct changes to the TextView currently on the screen.

  1. Create a new XML resource file in the res/anim directory named slide_out_top.xml, and open this in an editor or IDE.
  2. Declare a y-translate animation from 0% to 100% as the only element in the animation resource:
    <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromYDelta="0%" android:toYDelta="-100%" ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.