Skip to content

Commit cb150fe

Browse files
committed
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
1 parent 5380cdc commit cb150fe

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

core/java/android/view/View.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,32 @@
537537
* themselves rather than by putting them in a separate structure.
538538
* </p>
539539
*
540+
* <a name="Properties"></a>
541+
* <h3>Properties</h3>
542+
* <p>
543+
* The View class exposes an {@link #ALPHA} property, as well as several transform-related
544+
* properties, such as {@link #TRANSLATION_X} and {@link #TRANSLATION_Y}. These properties are
545+
* available both in the {@link Property} form as well as in similarly-named setter/getter
546+
* methods (such as {@link #setAlpha(float)} for {@link #ALPHA}). These properties can
547+
* be used to set persistent state associated with these rendering-related properties on the view.
548+
* The properties and methods can also be used in conjunction with
549+
* {@link android.animation.Animator Animator}-based animations, described more in the
550+
* <a href="#Animation">Animation</a> section.
551+
* </p>
552+
*
540553
* <a name="Animation"></a>
541554
* <h3>Animation</h3>
542555
* <p>
556+
* Starting with Android 3.0, the preferred way of animating views is to use the
557+
* {@link android.animation} package APIs. These {@link android.animation.Animator Animator}-based
558+
* classes change actual properties of the View object, such as {@link #setAlpha(float) alpha} and
559+
* {@link #setTranslationX(float) translationX}. This behavior is contrasted to that of the pre-3.0
560+
* {@link android.view.animation.Animation Animation}-based classes, which instead animate only
561+
* how the view is drawn on the display. In particular, the {@link ViewPropertyAnimator} class
562+
* makes animating these View properties particularly easy and efficient.
563+
* </p>
564+
* <p>
565+
* Alternatively, you can use the pre-3.0 animation classes to animate how Views are rendered.
543566
* You can attach an {@link Animation} object to a view using
544567
* {@link #setAnimation(Animation)} or
545568
* {@link #startAnimation(Animation)}. The animation can alter the scale,
@@ -548,10 +571,6 @@
548571
* subtree rooted by that node. When an animation is started, the framework will
549572
* take care of redrawing the appropriate views until the animation completes.
550573
* </p>
551-
* <p>
552-
* Starting with Android 3.0, the preferred way of animating views is to use the
553-
* {@link android.animation} package APIs.
554-
* </p>
555574
*
556575
* <a name="Security"></a>
557576
* <h3>Security</h3>

core/java/android/view/ViewPropertyAnimator.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,20 @@ public ViewPropertyAnimator alphaBy(float value) {
624624
/**
625625
* The View associated with this ViewPropertyAnimator will have its
626626
* {@link View#setLayerType(int, android.graphics.Paint) layer type} set to
627-
* {@link View#LAYER_TYPE_HARDWARE} for the duration of the next animation. This state
628-
* is not persistent, either on the View or on this ViewPropertyAnimator: the layer type
629-
* of the View will be restored when the animation ends to what it was when this method was
630-
* called, and this setting on ViewPropertyAnimator is only valid for the next animation.
631-
* Note that calling this method and then independently setting the layer type of the View
632-
* (by a direct call to {@link View#setLayerType(int, android.graphics.Paint)}) will result
633-
* in some inconsistency, including having the layer type restored to its pre-withLayer()
634-
* value when the animation ends.
627+
* {@link View#LAYER_TYPE_HARDWARE} for the duration of the next animation.
628+
* As stated in the documentation for {@link View#LAYER_TYPE_HARDWARE},
629+
* the actual type of layer used internally depends on the runtime situation of the
630+
* view. If the activity and this view are hardware-accelerated, then the layer will be
631+
* accelerated as well. If the activity or the view is not accelerated, then the layer will
632+
* effectively be the same as {@link View#LAYER_TYPE_SOFTWARE}.
633+
*
634+
* <p>This state is not persistent, either on the View or on this ViewPropertyAnimator: the
635+
* layer type of the View will be restored when the animation ends to what it was when this
636+
* method was called, and this setting on ViewPropertyAnimator is only valid for the next
637+
* animation. Note that calling this method and then independently setting the layer type of
638+
* the View (by a direct call to {@link View#setLayerType(int, android.graphics.Paint)}) will
639+
* result in some inconsistency, including having the layer type restored to its pre-withLayer()
640+
* value when the animation ends.</p>
635641
*
636642
* @see View#setLayerType(int, android.graphics.Paint)
637643
* @return This object, allowing calls to methods in this class to be chained.

0 commit comments

Comments
 (0)