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.
- Create a new layout resource file named
res/layout/vanish.xmland open in an editor or IDE.
- At the root of the new layout, declare a
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
Buttonneeds 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" ...