to top
Android APIs
public class

GridLayoutAnimationController

extends LayoutAnimationController
java.lang.Object
   ↳ android.view.animation.LayoutAnimationController
     ↳ android.view.animation.GridLayoutAnimationController

Class Overview

A layout animation controller is used to animated a grid layout's children. While LayoutAnimationController relies only on the index of the child in the view group to compute the animation delay, this class uses both the X and Y coordinates of the child within a grid. In addition, the animation direction can be controlled. The default direction is DIRECTION_LEFT_TO_RIGHT | DIRECTION_TOP_TO_BOTTOM. You can also set the animation priority to columns or rows. The default priority is none. Information used to compute the animation delay of each child are stored in an instance of GridLayoutAnimationController.AnimationParameters, itself stored in the ViewGroup.LayoutParams of the view.

Summary

Nested Classes
class GridLayoutAnimationController.AnimationParameters The set of parameters that has to be attached to each view contained in the view group animated by the grid layout animation controller. 
XML Attributes
Attribute Name Related Method Description
android:columnDelay Fraction of the animation duration used to delay the beginning of the animation of each column. 
android:direction Direction of the animation in the grid. 
android:directionPriority Priority of the rows and columns. 
android:rowDelay Fraction of the animation duration used to delay the beginning of the animation of each row. 
[Expand]
Inherited XML Attributes
From class android.view.animation.LayoutAnimationController
Constants
int DIRECTION_BOTTOM_TO_TOP Animates the children starting from the bottom of the grid to the top.
int DIRECTION_HORIZONTAL_MASK Bitmask used to retrieve the horizontal component of the direction.
int DIRECTION_LEFT_TO_RIGHT Animates the children starting from the left of the grid to the right.
int DIRECTION_RIGHT_TO_LEFT Animates the children starting from the right of the grid to the left.
int DIRECTION_TOP_TO_BOTTOM Animates the children starting from the top of the grid to the bottom.
int DIRECTION_VERTICAL_MASK Bitmask used to retrieve the vertical component of the direction.
int PRIORITY_COLUMN Columns are animated first.
int PRIORITY_NONE Rows and columns are animated at the same time.
int PRIORITY_ROW Rows are animated first.
[Expand]
Inherited Constants
From class android.view.animation.LayoutAnimationController
[Expand]
Inherited Fields
From class android.view.animation.LayoutAnimationController
Public Constructors
GridLayoutAnimationController(Context context, AttributeSet attrs)
Creates a new grid layout animation controller from external resources.
GridLayoutAnimationController(Animation animation)
Creates a new layout animation controller with a delay of 50% for both rows and columns and the specified animation.
GridLayoutAnimationController(Animation animation, float columnDelay, float rowDelay)
Creates a new layout animation controller with the specified delays and the specified animation.
Public Methods
float getColumnDelay()
Returns the delay by which the children's animation are offset from one column to the other.
int getDirection()
Returns the direction of the animation.
int getDirectionPriority()
Returns the direction priority for the animation.
float getRowDelay()
Returns the delay by which the children's animation are offset from one row to the other.
void setColumnDelay(float columnDelay)
Sets the delay, as a fraction of the animation duration, by which the children's animations are offset from one column to the other.
void setDirection(int direction)
Sets the direction of the animation.
void setDirectionPriority(int directionPriority)
Specifies the direction priority of the animation.
void setRowDelay(float rowDelay)
Sets the delay, as a fraction of the animation duration, by which the children's animations are offset from one row to the other.
boolean willOverlap()
Indicates whether two children's animations will overlap.
Protected Methods
long getDelayForView(View view)
Returns the amount of milliseconds by which the specified view's animation must be delayed or offset.
[Expand]
Inherited Methods
From class android.view.animation.LayoutAnimationController
From class java.lang.Object

XML Attributes

android:columnDelay

Fraction of the animation duration used to delay the beginning of the animation of each column.

May be a floating point value, such as "1.2".

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol columnDelay.

Related Methods

android:direction

Direction of the animation in the grid.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
left_to_right0x0 Animates columns from left to right.
right_to_left0x1 Animates columns from right to left.
top_to_bottom0x0 Animates rows from top to bottom.
bottom_to_top0x2 Animates rows from bottom to top.

This corresponds to the global attribute resource symbol direction.

Related Methods

android:directionPriority

Priority of the rows and columns. When the priority is none, both rows and columns have the same priority. When the priority is column, the animations will be applied on the columns first. The same goes for rows.

Must be one of the following constant values.

ConstantValueDescription
none0 Rows and columns are animated at the same time.
column1 Columns are animated first.
row2 Rows are animated first.

This corresponds to the global attribute resource symbol directionPriority.

Related Methods

android:rowDelay

Fraction of the animation duration used to delay the beginning of the animation of each row.

May be a floating point value, such as "1.2".

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol rowDelay.

Related Methods

Constants

public static final int DIRECTION_BOTTOM_TO_TOP

Added in API level 1

Animates the children starting from the bottom of the grid to the top.

Constant Value: 2 (0x00000002)

public static final int DIRECTION_HORIZONTAL_MASK

Added in API level 1

Bitmask used to retrieve the horizontal component of the direction.

Constant Value: 1 (0x00000001)

public static final int DIRECTION_LEFT_TO_RIGHT

Added in API level 1

Animates the children starting from the left of the grid to the right.

Constant Value: 0 (0x00000000)

public static final int DIRECTION_RIGHT_TO_LEFT

Added in API level 1

Animates the children starting from the right of the grid to the left.

Constant Value: 1 (0x00000001)

public static final int DIRECTION_TOP_TO_BOTTOM

Added in API level 1

Animates the children starting from the top of the grid to the bottom.

Constant Value: 0 (0x00000000)

public static final int DIRECTION_VERTICAL_MASK

Added in API level 1

Bitmask used to retrieve the vertical component of the direction.

Constant Value: 2 (0x00000002)

public static final int PRIORITY_COLUMN

Added in API level 1

Columns are animated first.

Constant Value: 1 (0x00000001)

public static final int PRIORITY_NONE

Added in API level 1

Rows and columns are animated at the same time.

Constant Value: 0 (0x00000000)

public static final int PRIORITY_ROW

Added in API level 1

Rows are animated first.

Constant Value: 2 (0x00000002)

Public Constructors

public GridLayoutAnimationController (Context context, AttributeSet attrs)

Added in API level 1

Creates a new grid 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

public GridLayoutAnimationController (Animation animation)

Added in API level 1

Creates a new layout animation controller with a delay of 50% for both rows and columns and the specified animation.

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

public GridLayoutAnimationController (Animation animation, float columnDelay, float rowDelay)

Added in API level 1

Creates a new layout animation controller with the specified delays and the specified animation.

Parameters
animation the animation to use on each child of the view group
columnDelay the delay by which each column animation must be offset
rowDelay the delay by which each row animation must be offset

Public Methods

public float getColumnDelay ()

Added in API level 1

Returns the delay by which the children's animation are offset from one column to the other. The delay is expressed as a fraction of the animation duration.

Returns
  • a fraction of the animation duration

public int getDirection ()

Added in API level 1

Returns the direction of the animation. DIRECTION_HORIZONTAL_MASK and DIRECTION_VERTICAL_MASK can be used to retrieve the horizontal and vertical components of the direction.

Returns
  • the direction of the animation

public int getDirectionPriority ()

Added in API level 1

Returns the direction priority for the animation. The priority can be either PRIORITY_NONE, PRIORITY_COLUMN or PRIORITY_ROW.

Returns
  • the priority of the animation direction

public float getRowDelay ()

Added in API level 1

Returns the delay by which the children's animation are offset from one row to the other. The delay is expressed as a fraction of the animation duration.

Returns
  • a fraction of the animation duration

public void setColumnDelay (float columnDelay)

Added in API level 1

Sets the delay, as a fraction of the animation duration, by which the children's animations are offset from one column to the other.

Parameters
columnDelay a fraction of the animation duration

public void setDirection (int direction)

Added in API level 1

Sets the direction of the animation. The direction is expressed as an integer containing a horizontal and vertical component. For instance, DIRECTION_BOTTOM_TO_TOP | DIRECTION_RIGHT_TO_LEFT.

Parameters
direction the direction of the animation

public void setDirectionPriority (int directionPriority)

Added in API level 1

Specifies the direction priority of the animation. For instance, PRIORITY_COLUMN will give priority to columns: the animation will first play on the column, then on the rows.Z

Parameters
directionPriority the direction priority of the animation

public void setRowDelay (float rowDelay)

Added in API level 1

Sets the delay, as a fraction of the animation duration, by which the children's animations are offset from one row to the other.

Parameters
rowDelay a fraction of the animation duration

public boolean willOverlap ()

Added in API level 1

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

Protected Methods

protected long getDelayForView (View view)

Added in API level 1

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