Added in API level 1

LayoutAnimationController


open class LayoutAnimationController
kotlin.Any
   ↳ android.view.animation.LayoutAnimationController

A layout animation controller is used to animate the children of a layout or a view group. 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 android.view.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 android.view.animation.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 android.view.animation.LayoutAnimationController.AnimationParameters, itself stored in the android.view.ViewGroup.LayoutParams of the view.

Summary

Nested classes
open

The set of parameters that has to be attached to each view contained in the view group animated by the layout animation controller.

XML attributes
android:animation Animation to use on each child.
android:animationOrder The order in which the animations will be started.
android:delay Fraction of the animation duration used to delay the beginning of the animation of each child.
android:interpolator Interpolator used to interpolate the delay between the start of each animation.
Constants
static Int

Distributes the animation delays in the order in which view were added to their view group.

static Int

Randomly distributes the animation delays.

static Int

Distributes the animation delays in the reverse order in which view were added to their view group.

Public constructors

Creates a new layout animation controller from external resources.

Creates a new layout animation controller with a delay of 50% and the specified animation.

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

Public methods
open Animation!

Returns the animation applied to each child of the view group on which this controller is set.

Animation!

Returns the animation to be applied to the specified view.

open Float

Returns the delay by which the children's animation are offset.

open Interpolator!

Returns the interpolator used to interpolate the delays between the children.

open Int

Returns the order used to compute the delay of each child's animation.

open Boolean

Indicates whether the layout animation is over or not.

open Unit
setAnimation(context: Context!, resourceID: Int)

Sets the animation to be run on each child of the view group on which this layout animation controller is .

open Unit
setAnimation(animation: Animation!)

Sets the animation to be run on each child of the view group on which this layout animation controller is .

open Unit
setDelay(delay: Float)

Sets the delay, as a fraction of the animation duration, by which the children's animations are offset.

open Unit
setInterpolator(context: Context!, resourceID: Int)

Sets the interpolator used to interpolate the delays between the children.

open Unit
setInterpolator(interpolator: Interpolator!)

Sets the interpolator used to interpolate the delays between the children.

open Unit
setOrder(order: Int)

Sets the order used to compute the delay of each child's animation.

open Unit

Starts the animation.

open Boolean

Indicates whether two children's animations will overlap.

Protected methods
open Long

Returns the amount of milliseconds by which the specified view's animation must be delayed or offset.

open Int

Transforms the index stored in android.view.animation.LayoutAnimationController.AnimationParameters by the order returned by getOrder().

Properties
Animation!

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

Interpolator!

The interpolator used to interpolate the delays.

Random!

The randomizer used when the order is set to random.

XML attributes

android:animation

android:animation
Animation to use on each child.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:animationOrder

android:animationOrder
The order in which the animations will be started.

Must be one of the following constant values.

Constant Value Description
normal 0 Animations are started in the natural order.
random 2 Animations are started randomly.
reverse 1 Animations are started in the reverse order.

android:delay

android:delay
Fraction of the animation duration used to delay the beginning of the animation of each child.

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.

android:interpolator

android:interpolator
Interpolator used to interpolate the delay between the start of each animation.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Constants

ORDER_NORMAL

Added in API level 1
static val ORDER_NORMAL: Int

Distributes the animation delays in the order in which view were added to their view group.

Value: 0

ORDER_RANDOM

Added in API level 1
static val ORDER_RANDOM: Int

Randomly distributes the animation delays.

Value: 2

ORDER_REVERSE

Added in API level 1
static val ORDER_REVERSE: Int

Distributes the animation delays in the reverse order in which view were added to their view group.

Value: 1

Public constructors

LayoutAnimationController

Added in API level 1
LayoutAnimationController(
    context: Context!,
    attrs: AttributeSet!)

Creates a new layout animation controller from external resources.

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

LayoutAnimationController

Added in API level 1
LayoutAnimationController(animation: Animation!)

Creates a new layout animation controller with a delay of 50% and the specified animation.

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

LayoutAnimationController

Added in API level 1
LayoutAnimationController(
    animation: Animation!,
    delay: Float)

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

Parameters
animation Animation!: the animation to use on each child of the view group
delay Float: the delay by which each child's animation must be offset

Public methods

getAnimation

Added in API level 1
open fun getAnimation(): Animation!

Returns the animation applied to each child of the view group on which this controller is set.

Return
Animation! an android.view.animation.Animation instance

getAnimationForView

Added in API level 1
fun getAnimationForView(view: View!): Animation!

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 android.view.animation.LayoutAnimationController.AnimationParameters. This method is called by view groups to obtain the animation to set on a specific child.

Parameters
view View!: the view to animate
Return
Animation! an animation delayed by the number of milliseconds returned by getDelayForView(android.view.View)

getDelay

Added in API level 1
open fun getDelay(): Float

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

Return
Float a fraction of the animation duration

See Also

getInterpolator

Added in API level 1
open fun getInterpolator(): Interpolator!

Returns the interpolator used to interpolate the delays between the children.

Return
Interpolator! an android.view.animation.Interpolator

getOrder

Added in API level 1
open fun getOrder(): Int

Returns the order used to compute the delay of each child's animation.

Return
Int one of ORDER_NORMAL, ORDER_REVERSE or ORDER_RANDOM

isDone

Added in API level 1
open fun isDone(): Boolean

Indicates whether the layout animation is over or not. A layout animation is considered done when the animation with the longest delay is done.

Return
Boolean true if all of the children's animations are over, false otherwise

setAnimation

Added in API level 1
open fun setAnimation(
    context: Context!,
    resourceID: Int
): Unit

Sets the animation to be run on each child of the view group on which this layout animation controller is .

Parameters
context Context!: the context from which the animation must be inflated
resourceID Int: the resource identifier of the animation

setAnimation

Added in API level 1
open fun setAnimation(animation: Animation!): Unit

Sets the animation to be run on each child of the view group on which this layout animation controller is .

Parameters
animation Animation!: the animation to run on each child of the view group

setDelay

Added in API level 1
open fun setDelay(delay: Float): Unit

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 Float: a fraction of the animation duration

See Also

setInterpolator

Added in API level 1
open fun setInterpolator(
    context: Context!,
    resourceID: Int
): Unit

Sets the interpolator used to interpolate the delays between the children.

Parameters
context Context!: the context from which the interpolator must be inflated
resourceID Int: the resource identifier of the interpolator

setInterpolator

Added in API level 1
open fun setInterpolator(interpolator: Interpolator!): Unit

Sets the interpolator used to interpolate the delays between the children.

Parameters
interpolator Interpolator!: the interpolator

setOrder

Added in API level 1
open fun setOrder(order: Int): Unit

Sets the order used to compute the delay of each child's animation.

Parameters
order Int: one of ORDER_NORMAL, ORDER_REVERSE or ORDER_RANDOM

start

Added in API level 1
open fun start(): Unit

Starts the animation.

willOverlap

Added in API level 1
open fun willOverlap(): Boolean

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

Return
Boolean true if animations will overlap, false otherwise

Protected methods

getDelayForView

Added in API level 1
protected open fun getDelayForView(view: View!): Long

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 android.view.animation.LayoutAnimationController.AnimationParameters found in the view's android.view.ViewGroup.LayoutParams.

Parameters
view View!: the view for which to obtain the animation's delay
Return
Long a delay in milliseconds

getTransformedIndex

Added in API level 1
protected open fun getTransformedIndex(params: LayoutAnimationController.AnimationParameters!): Int

Transforms the index stored in android.view.animation.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 LayoutAnimationController.AnimationParameters!: the animation parameters containing the index
Return
Int a transformed index

Properties

mAnimation

Added in API level 1
protected var mAnimation: Animation!

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

mInterpolator

Added in API level 1
protected var mInterpolator: Interpolator!

The interpolator used to interpolate the delays.

mRandomizer

Added in API level 1
protected var mRandomizer: Random!

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