In Java:
R.animator.filename In XML:
@[package:]animator/filename
SYNTAX:
<setandroid:ordering=["together" | "sequentially"]><objectAnimatorandroid: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"]/><animatorandroid: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>
The file must have a single root element: either <set>, <objectAnimator>, or <valueAnimator>. You can group animation elements together inside the <set> element, including other <set> elements.
ELEMENTS:
<set>
A container that holds other animation elements (
<objectAnimator>,
<valueAnimator>, or other
<set> elements). Represents an
AnimatorSet.
You can specify nested <set> tags to further group animations together. Each <set> can define its own ordering attribute.
attributes:
android:ordering
Keyword. Specifies the play ordering of animations in this set.
Value
Description
sequentially
Play animations in this set sequentially
together (default)
Play animations in this set at the same time.
<objectAnimator>
Animates a specific property of an object over a specific amount of time. Represents an
ObjectAnimator.
attributes:
android:propertyName
String.
Required. The object's property to animate, referenced by its name. For example you can specify
"alpha" or
"backgroundColor" for a View object. The
objectAnimatorelement does not expose a
target attribute, however, so you cannot set the object to animate in the XML declaration. You have to inflate your animation XML resource by calling
loadAnimator() and call
setTarget() to set the target object that contains this property.
android:valueTo
float, int, or color.
Required. The value where the animated property ends. Colors are represented as six digit hexadecimal numbers (for example, #333333).
android:valueFrom
float, int, or color. The value where the animated property starts. If not specified, the animation starts at the value obtained by the property's get method. Colors are represented as six digit hexadecimal numbers (for example, #333333).
android:duration
int. The time in milliseconds of the animation. 300 milliseconds is the default.
android:startOffset
int. The amount of milliseconds the animation delays after
start() is called.
android:repeatCount
int. How many times to repeat an animation. Set to
"-1" to infinitely repeat or to a positive integer. For example, a value of
"1" means that the animation is repeated once after the initial run of the animation, so the animation plays a total of two times. The default value is
"0", which means no repetition.
android:repeatMode
int. How an animation behaves when it reaches the end of the animation.
android:repeatCount must be set to a positive integer or
"-1" for this attribute to have an effect. Set to
"reverse" to have the animation reverse direction with each iteration or
"repeat" to have the animation loop from the beginning each time.
android:valueType
Keyword. Do not specify this attribute if the value is a color. The animation framework automatically handles color values
Value
Description
intType
Specifies that the animated values are integers
floatType (default)
Specifies that the animated values are floats
<animator>
Performs an animation over a specified amount of time. Represents a
ValueAnimator.
attributes:
android:valueTo
float, int, or color.
Required. The value where the animation ends. Colors are represented as six digit hexadecimal numbers (for example, #333333).
android:valueFrom
float, int, or color.
Required. The value where the animation starts. Colors are represented as six digit hexadecimal numbers (for example, #333333).
android:duration
int. The time in milliseconds of the animation. 300ms is the default.
android:startOffset
int. The amount of milliseconds the animation delays after
start() is called.
android:repeatCount
int. How many times to repeat an animation. Set to
"-1" to infinitely repeat or to a positive integer. For example, a value of
"1" means that the animation is repeated once after the initial run of the animation, so the animation plays a total of two times. The default value is
"0", which means no repetition.
android:repeatMode
int. How an animation behaves when it reaches the end of the animation.
android:repeatCount must be set to a positive integer or
"-1" for this attribute to have an effect. Set to
"reverse" to have the animation reverse direction with each iteration or
"repeat" to have the animation loop from the beginning each time.
android:valueType
Keyword. Do not specify this attribute if the value is a color. The animation framework automatically handles color values.
Value
Description
intType
Specifies that the animated values are integers
floatType (default)
Specifies that the animated values are floats
EXAMPLE:
XML file saved at
res/animator/property_animator.xml:
In order to run this animation, you must inflate the XML resources in your code to an AnimatorSetobject, and then set the target objects for all of the animations before starting the animation set. CallingsetTarget() sets a single target object for all children of the AnimatorSet as a convenience. The following code shows how to do this:
Property AnimationAn animation defined in XML that modifies properties of the target object, such as background color or alpha value, over a set amount of time.FILE LOCATION:res/animator/fil