Build 1.0_r1(from source)

android.view.animation
Class LayoutAnimationController

java.lang.Object
  extended by android.view.animation.LayoutAnimationController
Direct Known Subclasses:
GridLayoutAnimationController

public class LayoutAnimationController
extends Object

A layout animation controller is used to animated a layout's, or a view group's, children. Each child uses the same animation but for every one of them, the animation starts at a different time. A layout animation controller is used by ViewGroup to compute the delay by which each child's animation start must be offset. The delay is computed by using characteristics of each child, like its index in the view group. This standard implementation computes the delay by multiplying a fixed amount of miliseconds by the index of the child in its parent view group. Subclasses are supposed to override getDelayForView(android.view.View) to implement a different way of computing the delay. For instance, a GridLayoutAnimationController will compute the delay based on the column and row indices of the child in its parent view group. Information used to compute the animation delay of each child are stored in an instance of LayoutAnimationController.AnimationParameters, itself stored in the ViewGroup.LayoutParams of the view.


Nested Class Summary
static class LayoutAnimationController.AnimationParameters
          The set of parameters that has to be attached to each view contained in the view group animated by the layout animation controller.
 
Field Summary
protected  Animation mAnimation
          The animation applied on each child of the view group on which this layout animation controller is set.
protected  Interpolator mInterpolator
          The interpolator used to interpolate the delays.
protected  Random mRandomizer
          The randomizer used when the order is set to random.
static int ORDER_NORMAL
          Distributes the animation delays in the order in which view were added to their view group.
static int ORDER_RANDOM
          Randomly distributes the animation delays.
static int ORDER_REVERSE
          Distributes the animation delays in the reverse order in which view were added to their view group.
 
Constructor Summary
LayoutAnimationController(Animation animation)
          Creates a new layout animation controller with a delay of 50% and the specified animation.
LayoutAnimationController(Animation animation, float delay)
          Creates a new layout animation controller with the specified delay and the specified animation.
LayoutAnimationController(Context context, AttributeSet attrs)
          Creates a new layout animation controller from external resources.
 
Method Summary
 Animation getAnimation()
          Returns the animation applied to each child of the view group on which this controller is set.
 Animation getAnimationForView(View view)
          Returns the animation to be applied to the specified view.
 float getDelay()
          Returns the delay by which the children's animation are offset.
protected  long getDelayForView(View view)
          Returns the amount of milliseconds by which the specified view's animation must be delayed or offset.
 Interpolator getInterpolator()
          Returns the interpolator used to interpolate the delays between the children.
 int getOrder()
          Returns the order used to compute the delay of each child's animation.
protected  int getTransformedIndex(LayoutAnimationController.AnimationParameters params)
          Transforms the index stored in LayoutAnimationController.AnimationParameters by the order returned by getOrder().
 boolean isDone()
          Indicates whether the layout animation is over or not.
 void setAnimation(Animation animation)
          Sets the animation to be run on each child of the view group on which this layout animation controller is .
 void setAnimation(Context context, int resourceID)
          Sets the animation to be run on each child of the view group on which this layout animation controller is .
 void setDelay(float delay)
          Sets the delay, as a fraction of the animation duration, by which the children's animations are offset.
 void setInterpolator(Context context, int resourceID)
          Sets the interpolator used to interpolate the delays between the children.
 void setInterpolator(Interpolator interpolator)
          Sets the interpolator used to interpolate the delays between the children.
 void setOrder(int order)
          Sets the order used to compute the delay of each child's animation.
 void start()
          Starts the animation.
 boolean willOverlap()
          Indicates whether two children's animations will overlap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDER_NORMAL

public static final int ORDER_NORMAL
Distributes the animation delays in the order in which view were added to their view group.

See Also:
Constant Field Values

ORDER_REVERSE

public static final int ORDER_REVERSE
Distributes the animation delays in the reverse order in which view were added to their view group.

See Also:
Constant Field Values

ORDER_RANDOM

public static final int ORDER_RANDOM
Randomly distributes the animation delays.

See Also:
Constant Field Values

mAnimation

protected Animation mAnimation
The animation applied on each child of the view group on which this layout animation controller is set.


mRandomizer

protected Random mRandomizer
The randomizer used when the order is set to random. Subclasses should use this object to avoid creating their own.


mInterpolator

protected Interpolator mInterpolator
The interpolator used to interpolate the delays.

Constructor Detail

LayoutAnimationController

public LayoutAnimationController(Context context,
                                 AttributeSet attrs)
Creates a new layout animation controller from external resources.

Parameters:
context - the Context the view group is running in, through which it can access the resources
attrs - the attributes of the XML tag that is inflating the layout animation controller

LayoutAnimationController

public LayoutAnimationController(Animation animation)
Creates a new layout animation controller with a delay of 50% and the specified animation.

Parameters:
animation - the animation to use on each child of the view group

LayoutAnimationController

public LayoutAnimationController(Animation animation,
                                 float delay)
Creates a new layout animation controller with the specified delay and the specified animation.

Parameters:
animation - the animation to use on each child of the view group
delay - the delay by which each child's animation must be offset
Method Detail

getOrder

public int getOrder()
Returns the order used to compute the delay of each child's animation.

Returns:
one of ORDER_NORMAL, ORDER_REVERSE or {@link #ORDER_RANDOM)

setOrder

public void setOrder(int order)
Sets the order used to compute the delay of each child's animation.

Parameters:
order - one of ORDER_NORMAL, ORDER_REVERSE or ORDER_RANDOM

setAnimation

public void setAnimation(Context context,
                         int resourceID)
Sets the animation to be run on each child of the view group on which this layout animation controller is .

Parameters:
context - the context from which the animation must be inflated
resourceID - the resource identifier of the animation
See Also:
setAnimation(Animation), getAnimation()

setAnimation

public void setAnimation(Animation animation)
Sets the animation to be run on each child of the view group on which this layout animation controller is .

Parameters:
animation - the animation to run on each child of the view group
See Also:
setAnimation(android.content.Context, int), getAnimation()

getAnimation

public Animation getAnimation()
Returns the animation applied to each child of the view group on which this controller is set.

Returns:
an Animation instance
See Also:
setAnimation(android.content.Context, int), setAnimation(Animation)

setInterpolator

public void setInterpolator(Context context,
                            int resourceID)
Sets the interpolator used to interpolate the delays between the children.

Parameters:
context - the context from which the interpolator must be inflated
resourceID - the resource identifier of the interpolator
See Also:
getInterpolator(), setInterpolator(Interpolator)

setInterpolator

public void setInterpolator(Interpolator interpolator)
Sets the interpolator used to interpolate the delays between the children.

Parameters:
interpolator - the interpolator
See Also:
getInterpolator(), setInterpolator(Interpolator)

getInterpolator

public Interpolator getInterpolator()
Returns the interpolator used to interpolate the delays between the children.

Returns:
an Interpolator

getDelay

public float getDelay()
Returns the delay by which the children's animation are offset. The delay is expressed as a fraction of the animation duration.

Returns:
a fraction of the animation duration
See Also:
setDelay(float)

setDelay

public void setDelay(float delay)
Sets the delay, as a fraction of the animation duration, by which the children's animations are offset. The general formula is:
 child animation delay = child index * delay * animation duration
 

Parameters:
delay - a fraction of the animation duration
See Also:
getDelay()

willOverlap

public boolean willOverlap()
Indicates whether two children's animations will overlap. Animations overlap when the delay is lower than 100% (or 1.0).

Returns:
true if animations will overlap, false otherwise

start

public void start()
Starts the animation.


getAnimationForView

public final Animation getAnimationForView(View view)
Returns the animation to be applied to the specified view. The returned animation is delayed by an offset computed according to the information provided by LayoutAnimationController.AnimationParameters. This method is called by view groups to obtain the animation to set on a specific child.

Parameters:
view - the view to animate
Returns:
an animation delayed by the number of milliseconds returned by getDelayForView(android.view.View)
See Also:
getDelay(), setDelay(float), getDelayForView(android.view.View)

isDone

public boolean isDone()
Indicates whether the layout animation is over or not. A layout animation is considered done when the animation with the longest delay is done.

Returns:
true if all of the children's animations are over, false otherwise

getDelayForView

protected long getDelayForView(View view)
Returns the amount of milliseconds by which the specified view's animation must be delayed or offset. Subclasses should override this method to return a suitable value. This implementation returns child animation delay milliseconds where:
 child animation delay = child index * delay
 
The index is retrieved from the LayoutAnimationController.AnimationParameters found in the view's ViewGroup.LayoutParams.

Parameters:
view - the view for which to obtain the animation's delay
Returns:
a delay in milliseconds
See Also:
getAnimationForView(android.view.View), getDelay(), getTransformedIndex(android.view.animation.LayoutAnimationController.AnimationParameters), ViewGroup.LayoutParams

getTransformedIndex

protected int getTransformedIndex(LayoutAnimationController.AnimationParameters params)
Transforms the index stored in LayoutAnimationController.AnimationParameters by the order returned by getOrder(). Subclasses should override this method to provide additional support for other types of ordering. This method should be invoked by getDelayForView(android.view.View) prior to any computation.

Parameters:
params - the animation parameters containing the index
Returns:
a transformed index

Build 1.0_r1(from source)

Please submit a feedback, bug or feature