public class GridLayoutAnimationController extends LayoutAnimationController
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.LayoutAnimationController
,
GridView
Modifier and Type | Class and Description |
---|---|
static 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.
|
Modifier and Type | Field and Description |
---|---|
static int |
DIRECTION_BOTTOM_TO_TOP
Animates the children starting from the bottom of the grid to the top.
|
static int |
DIRECTION_HORIZONTAL_MASK
Bitmask used to retrieve the horizontal component of the direction.
|
static int |
DIRECTION_LEFT_TO_RIGHT
Animates the children starting from the left of the grid to the right.
|
static int |
DIRECTION_RIGHT_TO_LEFT
Animates the children starting from the right of the grid to the left.
|
static int |
DIRECTION_TOP_TO_BOTTOM
Animates the children starting from the top of the grid to the bottom.
|
static int |
DIRECTION_VERTICAL_MASK
Bitmask used to retrieve the vertical component of the direction.
|
static int |
PRIORITY_COLUMN
Columns are animated first.
|
static int |
PRIORITY_NONE
Rows and columns are animated at the same time.
|
static int |
PRIORITY_ROW
Rows are animated first.
|
mAnimation, mInterpolator, mRandomizer, ORDER_NORMAL, ORDER_RANDOM, ORDER_REVERSE
Constructor and Description |
---|
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.
|
GridLayoutAnimationController(Context context,
AttributeSet attrs)
Creates a new grid layout animation controller from external resources.
|
Modifier and Type | Method and Description |
---|---|
float |
getColumnDelay()
Returns the delay by which the children's animation are offset from one
column to the other.
|
protected long |
getDelayForView(View view)
Returns the amount of milliseconds by which the specified view's
animation must be delayed or offset.
|
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.
|
getAnimation, getAnimationForView, getDelay, getInterpolator, getOrder, getTransformedIndex, isDone, setAnimation, setAnimation, setDelay, setInterpolator, setInterpolator, setOrder, start
public static final int DIRECTION_LEFT_TO_RIGHT
public static final int DIRECTION_RIGHT_TO_LEFT
public static final int DIRECTION_TOP_TO_BOTTOM
public static final int DIRECTION_BOTTOM_TO_TOP
public static final int DIRECTION_HORIZONTAL_MASK
public static final int DIRECTION_VERTICAL_MASK
public static final int PRIORITY_NONE
public static final int PRIORITY_COLUMN
public static final int PRIORITY_ROW
public GridLayoutAnimationController(Context context, AttributeSet attrs)
context
- the Context the view group is running in, through which
it can access the resourcesattrs
- the attributes of the XML tag that is inflating the
layout animation controllerpublic GridLayoutAnimationController(Animation animation)
animation
- the animation to use on each child of the view grouppublic GridLayoutAnimationController(Animation animation, float columnDelay, float rowDelay)
animation
- the animation to use on each child of the view groupcolumnDelay
- the delay by which each column animation must be offsetrowDelay
- the delay by which each row animation must be offsetpublic float getColumnDelay()
setColumnDelay(float)
,
getRowDelay()
,
setRowDelay(float)
public void setColumnDelay(float columnDelay)
columnDelay
- a fraction of the animation durationgetColumnDelay()
,
getRowDelay()
,
setRowDelay(float)
public float getRowDelay()
setRowDelay(float)
,
getColumnDelay()
,
setColumnDelay(float)
public void setRowDelay(float rowDelay)
rowDelay
- a fraction of the animation durationgetRowDelay()
,
getColumnDelay()
,
setColumnDelay(float)
public int getDirection()
DIRECTION_HORIZONTAL_MASK
and DIRECTION_VERTICAL_MASK
can be used to retrieve the
horizontal and vertical components of the direction.setDirection(int)
,
DIRECTION_BOTTOM_TO_TOP
,
DIRECTION_TOP_TO_BOTTOM
,
DIRECTION_LEFT_TO_RIGHT
,
DIRECTION_RIGHT_TO_LEFT
,
DIRECTION_HORIZONTAL_MASK
,
DIRECTION_VERTICAL_MASK
public void setDirection(int direction)
DIRECTION_BOTTOM_TO_TOP | DIRECTION_RIGHT_TO_LEFT
.direction
- the direction of the animationgetDirection()
,
DIRECTION_BOTTOM_TO_TOP
,
DIRECTION_TOP_TO_BOTTOM
,
DIRECTION_LEFT_TO_RIGHT
,
DIRECTION_RIGHT_TO_LEFT
,
DIRECTION_HORIZONTAL_MASK
,
DIRECTION_VERTICAL_MASK
public int getDirectionPriority()
PRIORITY_NONE
, PRIORITY_COLUMN
or
PRIORITY_ROW
.setDirectionPriority(int)
,
PRIORITY_COLUMN
,
PRIORITY_NONE
,
PRIORITY_ROW
public void setDirectionPriority(int directionPriority)
PRIORITY_COLUMN
will give priority to columns: the animation
will first play on the column, then on the rows.ZdirectionPriority
- the direction priority of the animationgetDirectionPriority()
,
PRIORITY_COLUMN
,
PRIORITY_NONE
,
PRIORITY_ROW
public boolean willOverlap()
willOverlap
in class LayoutAnimationController
protected long getDelayForView(View view)
child animation delay
milliseconds where:
child animation delay = child index * delayThe index is retrieved from the
LayoutAnimationController.AnimationParameters
found in the view's ViewGroup.LayoutParams
.getDelayForView
in class LayoutAnimationController
view
- the view for which to obtain the animation's delayLayoutAnimationController.getAnimationForView(android.view.View)
,
LayoutAnimationController.getDelay()
,
LayoutAnimationController.getTransformedIndex(android.view.animation.LayoutAnimationController.AnimationParameters)
,
ViewGroup.LayoutParams