Time for action - making a Button vanish

So how can we apply the nice shiny animation to a Button object? The Button object doesn't have an animation attribute, and so you can't just reference it from the layout resource file. What we want, is the animation to run when the Button widget is clicked.

  1. Create a new layout resource file named res/layout/vanish.xml and open in an editor or IDE.
  2. At the root of the new layout, declare a RelativeLayout element:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
    
  3. The Button needs to be nice and large, and centered on the screen. For this we give it some inner padding:
    <Button android:id="@+id/vanish" android:paddingTop="20dip" ...

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.