LayoutAnimationController is used to add an animation effect to a child view in layout or viewgroup. Each element in Layout uses the same animation effect, but the start time is different. The default start time of a child View animation is to multiply the serial number index of the Child View in Layout by a fixed interval. The subclass of LayoutAnimationController can overload getDelayForView (android. view. View) to define the animation start time for the Child View. For example, GridLayoutAnimationController calculates the start time of the Child View animation based on the row and column of the Child View.
In this example, a Fade-in animation is set for the GridView, And the icon in the App Launcher is used as the data source,
Set LayoutAnimation for the GridView:
<GridView xmlns: android = "http://schemas.android.com/apk/res/android"
Android: id = "@ + id/grid"
Android: layoutAnimation = "@ anim/layout_grid_fade"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: padding = "10dp"
Android: verticalSpacing = "10dp"
Android: horizontalSpacing = "10dp"
Android: numColumns = "auto_fit"
Android: columnWidth = "60dp"
Android: stretchMode = "columnWidth"
Android: gravity = "center"/>
Layout_grid_fade.xml is defined as follows:
<GridLayoutAnimation
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: rowDelay = "50%"
Android: direpripriority = "column"
Android: animation = "@ anim/fade"/>
GridLayoutAnimation defines the corresponding animation effect for each Cell in the Grid. android: animation = @ anim/fade.
ColumnDelay: defines the animation latency ratio of the GridView column.
Direction: defines the direction in which an animation occurs in sequence.
Direpripriority: the animation takes precedence over rows or columns.
RowDelay: defines the lag time ratio of the row animation in the GridView.
GridLayoutAnimation defines the sequence in which child cells start animation in sequence for the GridView. The specific animation of each Cell is defined by android: animation, in this example, @ anim/fade is used to define the animation effect (fade IN) of each Cell in the Grid ).
<Alpha xmlns: android = "http://schemas.android.com/apk/res/android"
Android: interpolator = "@ android: anim/accelerate_interpolator"
Android: fromAlpha = "0.0" android: toAlpha = "1.0 ″
Android: duration = "@ android: integer/config_longAnimTime"/>
Author: mapdigit