From cb150fe9e6495256019b02be51e736679b57c1b5 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 3 May 2012 15:15:05 -0700 Subject: [PATCH] Minor doc fixes for animation- and view-related things Issue #6016341 Add info about properties and ViewPropertyAnimator to View reference docs Issue #6441062 Misleading docs in ViewPropertyAnimator Change-Id: Ica7c026c770fe2e57013fe443ede5428cd6b6604 --- core/java/android/view/View.java | 27 ++++++++++++++++--- .../android/view/ViewPropertyAnimator.java | 22 +++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 092bcbd4b4ef2..21eb80bc6eb11 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -537,9 +537,32 @@ import java.util.concurrent.CopyOnWriteArrayList; * themselves rather than by putting them in a separate structure. *

* + * + *

Properties

+ *

+ * The View class exposes an {@link #ALPHA} property, as well as several transform-related + * properties, such as {@link #TRANSLATION_X} and {@link #TRANSLATION_Y}. These properties are + * available both in the {@link Property} form as well as in similarly-named setter/getter + * methods (such as {@link #setAlpha(float)} for {@link #ALPHA}). These properties can + * be used to set persistent state associated with these rendering-related properties on the view. + * The properties and methods can also be used in conjunction with + * {@link android.animation.Animator Animator}-based animations, described more in the + * Animation section. + *

+ * * *

Animation

*

+ * Starting with Android 3.0, the preferred way of animating views is to use the + * {@link android.animation} package APIs. These {@link android.animation.Animator Animator}-based + * classes change actual properties of the View object, such as {@link #setAlpha(float) alpha} and + * {@link #setTranslationX(float) translationX}. This behavior is contrasted to that of the pre-3.0 + * {@link android.view.animation.Animation Animation}-based classes, which instead animate only + * how the view is drawn on the display. In particular, the {@link ViewPropertyAnimator} class + * makes animating these View properties particularly easy and efficient. + *

+ *

+ * Alternatively, you can use the pre-3.0 animation classes to animate how Views are rendered. * You can attach an {@link Animation} object to a view using * {@link #setAnimation(Animation)} or * {@link #startAnimation(Animation)}. The animation can alter the scale, @@ -548,10 +571,6 @@ import java.util.concurrent.CopyOnWriteArrayList; * subtree rooted by that node. When an animation is started, the framework will * take care of redrawing the appropriate views until the animation completes. *

- *

- * Starting with Android 3.0, the preferred way of animating views is to use the - * {@link android.animation} package APIs. - *

* * *

Security

diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index ec37acf41d4b1..2012db2adb21a 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -624,14 +624,20 @@ public class ViewPropertyAnimator { /** * The View associated with this ViewPropertyAnimator will have its * {@link View#setLayerType(int, android.graphics.Paint) layer type} set to - * {@link View#LAYER_TYPE_HARDWARE} for the duration of the next animation. This state - * is not persistent, either on the View or on this ViewPropertyAnimator: the layer type - * of the View will be restored when the animation ends to what it was when this method was - * called, and this setting on ViewPropertyAnimator is only valid for the next animation. - * Note that calling this method and then independently setting the layer type of the View - * (by a direct call to {@link View#setLayerType(int, android.graphics.Paint)}) will result - * in some inconsistency, including having the layer type restored to its pre-withLayer() - * value when the animation ends. + * {@link View#LAYER_TYPE_HARDWARE} for the duration of the next animation. + * As stated in the documentation for {@link View#LAYER_TYPE_HARDWARE}, + * the actual type of layer used internally depends on the runtime situation of the + * view. If the activity and this view are hardware-accelerated, then the layer will be + * accelerated as well. If the activity or the view is not accelerated, then the layer will + * effectively be the same as {@link View#LAYER_TYPE_SOFTWARE}. + * + *

This state is not persistent, either on the View or on this ViewPropertyAnimator: the + * layer type of the View will be restored when the animation ends to what it was when this + * method was called, and this setting on ViewPropertyAnimator is only valid for the next + * animation. Note that calling this method and then independently setting the layer type of + * the View (by a direct call to {@link View#setLayerType(int, android.graphics.Paint)}) will + * result in some inconsistency, including having the layer type restored to its pre-withLayer() + * value when the animation ends.

* * @see View#setLayerType(int, android.graphics.Paint) * @return This object, allowing calls to methods in this class to be chained.