Java Reference
In-Depth Information
Wave'sclicklistenerinvokes
dukeAnimation.stop();
followedby
dukeAn-
imation.start();
to stop and then start the animation. The
stop()
method is
called before
start()
to ensure that a subsequent click of the Wave button causes a
new animation to begin.
Java7MeetsAndroid
relies onthreeXMLresourcefilesandseveral PNGimages.
Listing 12-4.
The
main.xml
file storing layout information that includes a pair of widgets
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/
apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#ffffff">
<ImageView android:id="@+id/duke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"/>
<Button android:id="@+id/wave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wave"/>
</LinearLayout>
that specifies a
layout
(a view group that arranges contained views on an Android
device'sscreeninsomemanner)forarrangingcontainedwidgets(includingnestedlay-
outs) either horizontally or vertically across the screen.
The
<LinearLayout>
tag specifies several attributes for controlling this linear
layout. These attributes include the following:
•
orientation
identifiesthelinearlayoutashorizontalorvertical-contained
widgets are laid out horizontally or vertically. The default orientation is hori-