A big cleanup of Android basic animations once done

Source: Internet
Author: User
Tags repetition

1.Tween Animation Transform animation alpha: Gradient Transparency Animation scale: Gradient dimension zoom Animation translate: Position move animation rotate: Rotate Animation Common Properties: (1) Duration: Animation duration (in milliseconds) (2) Fillafter: Set totrue, animation conversion is applied after the animation is finished (3) Fillbefore: Set totrue, animation conversions are applied before the animation starts (4) Interpolator: Animation Insert (acceleration, deceleration insert) (5) RepeatCount: Number of animation repetitions (6) Repatemode: Sequential repeat/reverse repetition (7) Startoffset: The time interval between animations (commonly used in composite animations) Animation implementation method (1) configuration file (/res/anim)-alpha, scale, translate, rotate (2) Java code Implementation-Alphaanimation, Scaleanimation, Translateanimation, rotateanimation2.Frame Animation Frames Animation3.Layout Animation Animation4.Property Animation Properties Animation tween Animation (transform animation)1.Common attributes: (1) Duration: Animation duration (in milliseconds) (2) Fillafter: Set totrue, animation conversion is applied after the animation is finished (3) Fillbefore: Set totrue, animation conversions are applied before the animation starts (4) Interpolator: Animation Insert (acceleration, deceleration insert) (5) RepeatCount: Number of animation repetitions (6) Repatemode: Sequential repeat/reverse repetition (7) Startoffset: Time interval between animations (commonly used in composite animations) Tween Animation (transform animation)1.Common attributes: (1) Duration: Animation duration (in milliseconds) (2) Fillafter: Set totrue, animation conversion is applied after the animation is finished (3) Fillbefore: Set totrue, animation conversions are applied before the animation starts (4) Interpolator: Animation Insert (acceleration, deceleration insert) (5) RepeatCount: Number of animation repetitions (6) Repatemode: Sequential repeat/reverse repetition (7Startoffset: Time interval between animations (combined animations are common)1.Transform animation (tweenanimation):<1> Category: Alpha gradient Transparency Animation scale gradient dimension animation translate position move animation rotate rotate Animation <2> Common Properties: Duration: Animation Duration (ms) Fillafter set totrue, animation conversion is applied after the end of the animation Fillbefore set totrue, the animation conversion is applied before the animation starts Interpolator animation (acceleration/deceleration) repeatcount repetition repatemode sequential/reverse repetition startoffset the interval between animations <3> Implementation: Configuration file (Res/anim)-alpha,scale,translate,rotate (for fixed situations) Java code Implementation-alphaanimation,scaleanimation, Translateanimation,rotateanimation2.Property Animation (Propertyanimation):3.Frame animation (frameanimation):4.Layout animation (layoutanimation):1.Tween Animation Transform Animation (animation limitations, just constantly call the system's OnDraw () method, wasting system resources, not easy to listen to the interaction) Alpha: Gradient Transparency Animation scale: Gradient dimension zoom Animation translate: Position move animation rotate: Rotation Animation Common Properties: (1) Duration: Animation duration (in milliseconds) (2) Fillafter: Set totrue, animation conversion is applied after the animation is finished (3) Fillbefore: Set totrue, animation conversions are applied before the animation starts (4) Interpolator: Animation Insert (acceleration, deceleration insert) (5) RepeatCount: Number of animation repetitions (6) Repatemode: Sequential repeat/reverse repetition (7) Startoffset: The time interval between animations (commonly used in composite animations) Animation implementation method (1) configuration file (/res/anim)-alpha, scale, translate, rotate (2) Java code Implementation-Alphaanimation, Scaleanimation, Translateanimation, rotateanimation2.Frame Animation Frames Animation3.Layout Animation Animation4.Property Animation Properties Animation
Four basic animations for alphaanimation (transparency animation)

Transparency Animation.
Fromalpha transparency at start of animation
Toalpha transparency at end of animation
0.0 means full transparency 1.0 means completely opaque

Scaleanimation (zoom animation)

(1) Fromx,tox is the scaling size at the start and end of the x-coordinate, respectively
(2) Fromy,toy are the scaling dimensions at the start and end of the y-coordinate respectively.
(3) Pivotx,pivoty where the Flex animation begins relative to the x, y coordinates, respectively

Translateanimation (Displacement animation)

(1) Fromxdelta,fromydelta is the coordinates of x, Y, respectively.
(2) Toxdelta,toydelta is the coordinates of x, Y, respectively.

Rotateanimation (rotate animation)

(1) Angle of fromdegrees initiation
(2) Angle of todegrees termination
(3) Pivotx,pivoty the coordinates of the rotation animation relative to x, Y, respectively start position

Create an animation profile Alpha:<set>--<alpha android:duration="+"Fromalpha=0.1Toalpha=1.0/></set>scale:<set>------<scale duration= -Fillafter=false--------------fromxscale=0.0fromyscale=0.0---------------interpolator=xxxxxx---------------pivotx=0% pivoty=0% Zoom from Picture Center---------------toxscale=1.0toyscale=1.0/></set>translate: Configuring duration= -Fromxdelta=TenFromydelta=TenStarting point--------------------toxdelta= -Toydelta= -Add rotate label to end Rotate:set label set fromdegrees todegrees start angle, end angle--------------------------Rotation center pivotx= -% pivoty= -%
Examples of special effects

Activity Toggle Animation:
Use the Overridependingtransition method.
Parameters: The second activity enters the animation, the first activity exits when the animation

Layoutanimation (layout animation)

Add animations to the view groups, using Layoutanimationcontroller
Layoutanimation can be used to animate the view groups and, in a predetermined order, apply an animation (or animation collection) to every child view in the view group. You can use Layoutanimationcontroller to specify an animation that applies to each of the child view in the ViewGroup

//布局动画使用LayoutAnimationController lac=new LayoutAnimationController(AnimationUtils.loadAnimation(this,R.anim.zoom_in));lac.setOrder(LayoutAnimationController.ORDER_RANDOM);//指定动画顺序listView.setLayoutAnimation(lac);//加载布局动画listView.startLayoutAnimation();
Frameanimation (per-frame animation)

Use the animation-list tag to group an item tag collection, define the picture to display, and specify the time (in milliseconds) to display it
Frameanimation Frames-per-frame animations Create a new XML (such as a anim_list.xml) file under the Drawable file and use the animation-list tag to group A collection of item tags.

//Flashback repeat reverse positive sequence repeat restartAlphaanimation.setrepeatmode (animation.reverse); combo Animation--Resume one: Two loaders, and set the listener for the first animation (three ways to make a replication, Open the second animated loader in Onanimationend () The activity Toggle animation uses the Overridependingtransition method parameter: The animation of the second activity entry-------the animation startactivity (intent) when the first activity exited, overridependingtransition (r.anim.zoom_in, R.anim.zoom_out) animation can set the listener Onanimationlistener, which in this listener has3method, we can implement different logic animation objects according to the function we want to implement. Setanimationlistener () listens for events at the beginning or end of an animation to be set in the configuration file Startoffset You can delay the playback of frame-wise animations frameanimation with a <animation-list> tag containing multiple <item android:drawable=@drawable/one|two|tree duration= -> Label layoutanimation layout Animations Add an animated Layoutanimationcontroller to the layout animation controller lac=NewLayoutanimationcontroller (Animationutils.loadaniamtion ( This, r.anim.zoom_in)) Set load order Lac.setorder (Layoutanimationcontroller.order_random) ListView Load Animation listview.setlayoutanimation (LAC) Start animation listview.startlayoutanimation ()

A big cleanup of Android basic animations once done

Related Article

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.