Android App Resource---animation resource (Animation resources)

Source: Internet
Author: User

There are two types of animation resources: Property Animation creates an animation within a set time by modifying the property values of the object associated with the animator class. View animations have two types of view animation frame motion Tweens (Tween animation): Create animations by performing a series of transformations on a single picture associated with the animation class.   Frame animation (frame animation): Creates an animation by displaying a sequence of pictures related to the order of the Animationdrawable class.   Properties Animation   animation is defined in the XML of the target object's properties to be modified, such as the background color or alpha value within the set time.   File location:  res/animator/filename.xml, file name is used as resource ID.   Compiled resource type (COMPILED rsource DATATYPE):  resource to point to Valueanimator, Objectanimator, or Animatorset type resource reference (RESOURCE REFERENCE): :r.animation.filename  in the Java Code:@[package:]animator/filename  Syntax (SYNTAX) in the XML file:  <set  android:ordering=["Together" | "Sequentially"]>   http://www.huiyi8.com/jiaoben/    <objectAnimator        Android:propertyname= "string"         android:duration= "int"         android:valuefrom= "float | int | Color "        android:valueto=" float | int | Color         android:startoffset= "int"         android:repeatcount= "int"         android:repeatmode=["repeat" | "Reverse"]        android:valuetype=["Inttype" | "Floattype"]/>     <animator        android:duration= "int"         android:valuefrom= "float | int | Color "        android:valueto=" float | int | Color         android:startoffset= "int"         android:repeatcount= "int"         android:repeatmode=["repeat" | "Reverse"]        android:valuetype=["Inttype" | "Floattype"]/>     <set>        ...    </set></set>& nbsp; This file must have a single element: either <set>, <objectAnimator> or <valueAnimator>. You can organize animation elements together into <set> elements, including other <set> elements.   Elements (ELEMENTS): <set>     A container that can contain other animated elements (<objectAnimator>, <valueanimator >, or other <set> yuan(vegetarian). Represents a Animatorset object.     You can specify <set> nested tags to organize more animations together. Each <set> is able to define its own order properties.   Properties (ATTRIBUTES):     android:ordering  Key property that specifies the order in which the animations in the collection are played.   Values   Description  sequentially  play the animation sequentially in this set of collections.  together (default)   Play the animation in this group collection at the same time  <objectAnimator>     specific animated properties of an object within a specific set time, Represents a Objectanimator object.   Properties (ATTRIBUTES):     android:propertyname         String type, required. This name is used to refer to the animated object properties. For example, you can assign an "alpha" or "backgroundcolor" property to a View object. The Objectanimator element does not expose the target property, so you cannot set an object to animate in an XML declaration. The animation XML resource must be populated into the target object that contains the property by calling the Loadanimator () method and the Settarget () method.      android:valueto         floating-point type, integer, or color value, required. It is the end value of the animation property. The color is expressed in six hexadecimal digits (such as #333333).      android:valuefrom         floating-point type, integer, or color value, which is the starting value of the animation property, if not specified, Then the animation starts at the moment when the value is fetched with the property's Get method. The color is a six-digit hexadecimal number representation (such as #333333).      android:duration         integer types. Specifies the animation time in milliseconds, which is 300 milliseconds by default.      android:startoffset         integer types. The number of milliseconds that the animation is delayed after the start () method is called.      android:repeatcount         integer types. Specifies the number of repetitions of the animation. Set to "1", indicating that you want to repeat indefinitely, or specify a positive integer. For example, set to 1, which indicates that the animation is repeated once after the first run, so the animation is played two times. The default value is 0, which means that it is not duplicated.      android:repeatmode         positive integers. Specifies how the animation behaves when it reaches the end. This property is effective only if Android:repeatcount is set to a positive integer or "1". If set to "reverse", the animation will play backwards each time it repeats, and if set to "repeat", the animation will be played from the beginning of the animation each time it repeats.      android:valuetype         key properties. If the value is a color value, then this property is not specified. The animation frame automatically handles color values.   Value   Description  intType  The value of the specified animation is an integer  floattype (default)   The value of the specified animation is a floating point  <animator>  The animation within the set time. Represents a Valueanimator object.   Properties (ATTRIBUTES):     android:valueto         Floating-point, Integer, or color values, required. It is the value of the end of the animation. Color values are represented by a six-digit hexadecimal number (for example, #333333)      android:valuefrom         float, integer, or color values, required. It is the value at which the animation begins. Color values are represented by a six-digit hexadecimal number (e.g., #333333)      ANDROID:DURATION&Nbsp;        integers. Specifies the playback time of the animation, in milliseconds. The default is 300 milliseconds.      android:startoffset         integers. Specifies the number of milliseconds that the animation is delayed after the start () method is called.      android:repeatcount         integers. Specifies the number of repetitions of the animation. If set to "1", the animation repeats indefinitely, or a positive integer is specified. For example, when set to "1", the animation plays again once after the initial run, so the animation is played two times in total. Its default value is 0, which means that the animation repeats.       android:repeatMode         integer. It specifies how the animation repeats when it reaches the end. This property only works if the Android:repeatcount must be set to a positive integer or "1". If set to "reverse", the animation will play backwards each time it is replayed, and if it is set to "repeat", then the animation will start again each time it is replayed.       android:valueType         key attributes, if the value is a color, do not specify this property. Because the animation frame automatically handles the color values   values   Description  intType  The value of the specified animation is an integer  floattype (default)   The value of the specified animation is a floating point   Example (EXAMPLE):  This XML file is saved in Res/animator/property_animator.xml: <set android:ordering= "sequentially" >    <set>        <objectAnimator            Andro Id:propertyname= "x" &nbsP           android:duration= "$"           android:valueto= "400" & nbsp           android:valuetype= "Inttype"/>        <objectAnimator            android:propertyname= "y"             android:duration= "50 0 "            android:valueto=" "            Android:valuety Pe= "Inttype"/>    </set>    <objectAnimator        Android: Propertyname= "Alpha"         android:duration= "$"         android:valueto= "1f" /></set> AD Code   to run this animation, you must populate the code with the XML resource into a Animatorset object, and then set the target object to all animations before starting the animation set. Calling the Settarget method makes it easy to set a single object to all child objects of the Animatorset object. The code is as follows:  animatorset set = (Animatorset) animatorinflater.loadanimator (mycontext,    r.anim.property_ animator);  set.sEttarget (MyObject); Set.start ();

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.