Most visited

Recently visited

Added in API level 1

TranslateAnimation

public class TranslateAnimation
extends Animation

java.lang.Object
   ↳ android.view.animation.Animation
     ↳ android.view.animation.TranslateAnimation


An animation that controls the position of an object. See the full package description for details and sample code.

Summary

Inherited XML attributes

From class android.view.animation.Animation

Inherited constants

From class android.view.animation.Animation

Public constructors

TranslateAnimation(Context context, AttributeSet attrs)

Constructor used when a TranslateAnimation is loaded from a resource.

TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)

Constructor to use when building a TranslateAnimation from code

TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)

Constructor to use when building a TranslateAnimation from code

Public methods

void initialize(int width, int height, int parentWidth, int parentHeight)

Initialize this animation with the dimensions of the object being animated as well as the objects parents.

Protected methods

void applyTransformation(float interpolatedTime, Transformation t)

Helper for getTransformation.

Inherited methods

From class android.view.animation.Animation
From class java.lang.Object

Public constructors

TranslateAnimation

Added in API level 1
TranslateAnimation (Context context, 
                AttributeSet attrs)

Constructor used when a TranslateAnimation is loaded from a resource.

Parameters
context Context: Application context to use
attrs AttributeSet: Attribute set from which to read values

TranslateAnimation

Added in API level 1
TranslateAnimation (float fromXDelta, 
                float toXDelta, 
                float fromYDelta, 
                float toYDelta)

Constructor to use when building a TranslateAnimation from code

Parameters
fromXDelta float: Change in X coordinate to apply at the start of the animation
toXDelta float: Change in X coordinate to apply at the end of the animation
fromYDelta float: Change in Y coordinate to apply at the start of the animation
toYDelta float: Change in Y coordinate to apply at the end of the animation

TranslateAnimation

Added in API level 1
TranslateAnimation (int fromXType, 
                float fromXValue, 
                int toXType, 
                float toXValue, 
                int fromYType, 
                float fromYValue, 
                int toYType, 
                float toYValue)

Constructor to use when building a TranslateAnimation from code

Parameters
fromXType int: Specifies how fromXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
fromXValue float: Change in X coordinate to apply at the start of the animation. This value can either be an absolute number if fromXType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
toXType int: Specifies how toXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
toXValue float: Change in X coordinate to apply at the end of the animation. This value can either be an absolute number if toXType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
fromYType int: Specifies how fromYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
fromYValue float: Change in Y coordinate to apply at the start of the animation. This value can either be an absolute number if fromYType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
toYType int: Specifies how toYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
toYValue float: Change in Y coordinate to apply at the end of the animation. This value can either be an absolute number if toYType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.

Public methods

initialize

Added in API level 1
void initialize (int width, 
                int height, 
                int parentWidth, 
                int parentHeight)

Initialize this animation with the dimensions of the object being animated as well as the objects parents. (This is to support animation sizes being specified relative to these dimensions.)

Objects that interpret Animations should call this method when the sizes of the object being animated and its parent are known, and before calling getTransformation(long, Transformation).

Parameters
width int: Width of the object being animated
height int: Height of the object being animated
parentWidth int: Width of the animated object's parent
parentHeight int: Height of the animated object's parent

Protected methods

applyTransformation

Added in API level 1
void applyTransformation (float interpolatedTime, 
                Transformation t)

Helper for getTransformation. Subclasses should implement this to apply their transforms given an interpolation value. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.

Parameters
interpolatedTime float: The value of the normalized time (0.0 to 1.0) after it has been run through the interpolation function.
t Transformation: The Transformation object to fill in with the current transforms.

Hooray!