Android ApiDemos example resolution (126): Views-& gt; Layout Animation-& am

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.