Listing 1114 resanimanimatedxml

<?xml version="1.0" encoding="utf-8"?>

<animation-list xmlns:android="" android:oneshot="false">

<item android:drawable="@drawable/anddev1 <item android:drawable="@drawable/anddev2 <item android:drawable="@drawable/anddev3 </animation-list>

To display the frame-by-frame animation, set the animation to a view's background:

ImageView im = (ImageView) this.findViewByld(; im.setBackgroundResource(R.anim.animated);

AnimationDrawable ad = (AnimationDrawable)im.getBackground(); ad.start();

After the view background is set, a drawable can be retrieved by calling getBackground() and casting it to AnimationDrawable.Then, calling the start() method starts the animation.

Tween animation uses a different approach that creates an animation by performing a series of transformations on a single image. In Android, it provides access to the following classes that are the basis for all the animations:

■ AlphaAnimation—Controls transparency changes

■ RotateAnimation—Controls rotations

■ ScaleAnimation—Controls growing or shrinking

■ TranslateAnimation—Controls position changes

" android:duration="200" /> " android:duration="200" /> " android:duration="200" />

These four Animation classes can be used for transitions between activities, layouts, views and so on.All these can be defined in the layout XML file as <alpha>, <rotate>, <scale>, and <translate>.They all have to be contained within an AnimationSet <set>:

■ <alpha> attributes: android:fromAlpha, android:toAlpha

The alpha value translates the opacity from 0.0 (transparent) to 1.0 (opaque).

■ <rotate> attributes: android:fromDegrees, android:toDegrees, android:pivotX, android:pivotY

The rotate specifies the angle to rotate an animation around a center of rotation defined as the pivot.

■ <scale> attributes: android:fromXScale, android:toXScale, android:fromYScale, android:toYScale, android:pivotX, android:pivotY

The scale specifies how to change the size of a view in the x-axis or y-axis.The pivot location that stays fixed under the scaling can also be specified.

■ <translate> attributes: android:fromXDelta, android:toXDelta, android:fromYDelta, android:toYDelta

The translate specifies the amount of translation to perform on a View.

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment