Elements and Attributes

A container that can recursively hold itself or other animations. Represents an AnimationSet. You can include as many child elements of the same or different types as you like. Supports the following attribute:

• sharelnterpolator - Whether to share the same Interpolator among all immediate child elements. <alpha>

A fading animation. Represents an AlphaAnimation. Supports the following attributes:

• fromAlpha - 0.0 to 1.0, where 0.0 is transparent.

• toAlpha - 0.0 to 1.0, where 0.0 is transparent.

A resizing animation. Represents a ScaleAnimation. You can specify what is the center point of the image (the pinned center), from which it grows outward (or inward), by specifying pivotX and pivotY. So, for example, if these were 0, 0 (top left corner), all growth would be down and to the right. scale supports the following attributes:

• fromXScale - Starting X size, where 1.0 is no change.

• toXScale - Ending X size, where 1.0 is no change.

• fromYScale - Starting Y size, where 1.0 is no change.

• toYScale - Ending Y size, where 1.0 is no change.

• pivotX - The X coordinate of the pinned center.

• pivotY - The Y coordinate of the pinned center.

<translate>

A vertical/horizontal motion animation. Represents a TranslateAnimation. Supports the following attributes in any of the following three formats: values from -100 to 100, ending with "%", indicating a percentage relative to itself; values from -100 to 100, ending in "%p", indicating a percentage relative to its parent; a float with no suffix, indicating an absolute value.

• fromXDelta - Starting X location.

• fromYDelta - Starting Y location.

<rotate>

A rotation animation. Represents a RotateAnimation. Supports the following attributes:

• fromDegrees - Starting rotation, in degrees.

• toDegrees - Ending rotation, in degrees.

• pivotX - The X coordinate of the center of rotation, in pixels, where (0,0) is the top left corner.

• pivotY - The Y coordinate of the center of rotation, in pixels, where (0,0) is the top left corner.

interpolator tag>

You can also use any of the interpolator subclass elements defined in R.styleable. Examples include <CycleInterpolator>, <EaseInInterpolator>, and <EaseOutInterpolator>. These objects define a velocity curve that describes how quickly a visual action takes place on a timeline (fast at first and slow later, slow at first and gradually faster, and so on).

In addition to the attributes defined for each element above, the elements <alpha>, <scale>, <translate>, <rotate>, and <set> all support the following attributes (inherited from the Animation class):

duration

Duration, in milliseconds, for this effect.

startOffset

Offset start time for this effect, in milliseconds. fillBefore

When set true, the animation transformation is applied before the animation begins. fillAfter

When set true, the animation transformation is applied after the animation ends. repeatCount

Defines the number of times the animation should repeat. repeatMode

Defines the animation behavior when it reaches the end and the repeat count is greater than 0. Options are to either restart or reverse the animation.

zAdjustment

Defines the z-axis ordering mode to use when running the animation (normal, top, or bottom). interpolator

You can optionally set an interpolator for each element to determine how quickly or slowly it performs its effect over time. For example, slow at the beginning and faster at the end for EaseInInterpolator, and the reverse for EaseOutInterpolator. A list of interpolators is given in R.anim. To specify these, use the syntax @android:anim/interpolatorName.

For more discussion and animation code samples, see the discussion in the 2D Graphics document.

0 0

Post a comment