diff --git a/docs/html/guide/topics/graphics/animation.jd b/docs/html/guide/topics/graphics/animation.jd index 0b02ee767e7d6..31e7c4b79e9e0 100644 --- a/docs/html/guide/topics/graphics/animation.jd +++ b/docs/html/guide/topics/graphics/animation.jd @@ -81,6 +81,12 @@ parent.link=index.html If view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system.
+Tip: To see how the ADT layout editor allows you to develop and +preview animations in your layout, watch the Android +Developer Tools session from Google I/O '11
+ +<set>Both <animator> ({@link android.animation.ValueAnimator}) and
- <objectAnimator> ({@link android.animation.ObjectAnimator}) have the following
- attributes:
See Animation Resources -
android:durationandroid:valueFrom and android:valueTofloat or
- int) and color values (such as #00ff00). They can be float, int, colors,
- or any kind of Object when creating animations programmatically.android:valueType"floatType" or "intType". The default is
- "floatType" unless you specify something else or if the valuesFrom
- and valuesTo values are colors.android:startOffsetandroid:repeatCount"-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:repeatModeandroid: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.The <objectAnimator> ({@link android.animation.ObjectAnimator}) element has the
- additional attribute android:propertyName, that lets you specify the name of the
-property
- being animated. The <objectAnimator> element does not expose a target
- attribute, however, so you cannot set the object to animate in the XML declaration. You have to
- inflate the XML resource by calling {@link android.animation.AnimatorInflater#loadAnimator
- loadAnimator()} and call {@link android.animation.ObjectAnimator#setTarget setTarget()} to set
- the target object unlike the underlying {@link android.animation.ObjectAnimator},
- before calling {@link android.animation.ObjectAnimator#start start()}.
The <set> element ({@link android.animation.AnimatorSet}) exposes a single
- attribute, android:ordering. Set this attribute to "together" (default)
-to play
- all the animations in this set at once. Set this attribute to "sequentially" to play
- the animations in the order they are declared.
You can specify nested <set> elements to further group animations together.
-The
- animations that you want to group together should be children of the <set> tag and can
- define their own ordering attribute.
As an example, this XML code creates an {@link android.animation.AnimatorSet} object that - animates x and y at the same time, then runs an animation that fades an object out:
--<set android:ordering="sequentially"> - <set> - <objectAnimator - android:propertyName="x" - android:duration="500" - android:valueTo="400" - android:valueType="int"/> - <objectAnimator - android:propertyName="y" - android:duration="500" - android:valueTo="300" - android:valueType="int"/> - </set> - <objectAnimator - android:propertyName="alpha" - android:duration="500" - android:valueTo="0f"/> -</set> -- -
In order to run this animation, you must inflate the XML resources in your code to an {@link - android.animation.AnimatorSet} object, and then set the target objects for all of the animations - before starting the animation set. Calling {@link android.animation.AnimatorSet#setTarget - setTarget()} sets a single target object for all children of the {@link - android.animation.AnimatorSet}.
- -Tip: To see how the ADT layout editor allows you to develop and -preview animations in your layout, watch the Android -Developer Tools session from Google I/O '11
diff --git a/docs/html/guide/topics/resources/animation-resource.jd b/docs/html/guide/topics/resources/animation-resource.jd index 972dd729cb1df..3df669c06eb71 100644 --- a/docs/html/guide/topics/resources/animation-resource.jd +++ b/docs/html/guide/topics/resources/animation-resource.jd @@ -5,28 +5,348 @@ parent.link=available-resources.htmlAn animation resource can define one of two types of animations:
+There are two types of animations that you can do with the view animation framework:
+An animation defined in XML that modifies properties of the target object, such as +background color or alpha value, over a set amount of time.
-res/animator/filename.xmlR.animator.filename@[package:]animator/filename
++<set + android:ordering=["together" | "sequentially"]> + + <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> ++ +
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.
+
res/animator/property_animator.xml:
++<set android:ordering="sequentially"> + <set> + <objectAnimator + android:propertyName="x" + android:duration="500" + android:valueTo="400" + android:valueType="intType"/> + <objectAnimator + android:propertyName="y" + android:duration="500" + android:valueTo="300" + android:valueType="intType"/> + </set> + <objectAnimator + android:propertyName="alpha" + android:duration="500" + android:valueTo="1f"/> +</set> ++
In order to run this animation, you must inflate the XML resources in your code to an {@link + android.animation.AnimatorSet} object, and then set the target objects for all of the animations + before starting the animation set. Calling {@link android.animation.AnimatorSet#setTarget + setTarget()} sets a single target object for all children of the {@link + android.animation.AnimatorSet} as a convenience. The following code shows how to do this:
+ ++AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(myContext, + R.anim.property_animator); +set.setTarget(myObject); +set.start(); ++ + +
An animation defined in XML that performs transitions such as rotating, fading, moving, and stretching on a graphic. @@ -254,18 +574,14 @@ image.{@link android.view.View#startAnimation(Animation) startAnimation}(hypersp
An interpolator is an animation modifier defined in XML that affects the rate of change in an animation. This allows your existing animation effects to be accelerated, decelerated, repeated, @@ -456,22 +772,7 @@ sinusoidal pattern. - - - - - - - - - - - - - - - -
An animation defined in XML that shows a sequence of images in order (like a film).
@@ -562,7 +863,11 @@ rocketAnimation.{@link android.graphics.drawable.AnimationDrawable#start()}; +