From 14efe881d43d8916c42ef53940aa6e47c3a94e74 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Mon, 14 Nov 2016 13:27:38 -0800 Subject: [PATCH] Update the documentation related to VD / AVD fix:32705240 fix:32683765 fix:32831830 fix:32705244 Test: make offline-sdk-docs and view the HTML file. Merged-In: I6ae3e5850494f13a241b2e9e4d2c5b95d5199aae Change-Id: I6ae3e5850494f13a241b2e9e4d2c5b95d5199aae --- .../drawable/AnimatedVectorDrawable.java | 88 ++++++++++++++++--- .../graphics/drawable/VectorDrawable.java | 73 +++++---------- 2 files changed, 99 insertions(+), 62 deletions(-) diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java index c24d31334be00..659725ef59f66 100644 --- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java @@ -15,14 +15,14 @@ package android.graphics.drawable; import android.animation.Animator; +import android.animation.Animator.AnimatorListener; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; -import android.animation.Animator.AnimatorListener; +import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; -import android.animation.ObjectAnimator; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityThread; @@ -55,8 +55,8 @@ import android.view.RenderNodeAnimatorSetHelper; import android.view.View; import com.android.internal.R; - import com.android.internal.util.VirtualRefBasePtr; + import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -88,9 +88,77 @@ import java.util.ArrayList; * *
  • XML for the VectorDrawable containing properties to be animated

    *

    - * Animations can be performed on both group and path attributes, which requires groups and paths to - * have unique names in the same VectorDrawable. Groups and paths without animations do not need to - * be named. + * Animations can be performed on the animatable attributes in + * {@link android.graphics.drawable.VectorDrawable}. These attributes will be animated by + * {@link android.animation.ObjectAnimator}. The ObjectAnimator's target can be the root element, + * a group element or a path element. The targeted elements need to be named uniquely within + * the same VectorDrawable. Elements without animation do not need to be named. + *

    + *

    + * Here are all the animatable attributes in {@link android.graphics.drawable.VectorDrawable}: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Element NameAnimatable attribute name
    <vector>alpha
    <group>rotation
    pivotX
    pivotY
    scaleX
    scaleY
    translateX
    translateY
    <path>pathData
    fillColor
    strokeColor
    strokeWidth
    strokeAlpha
    fillAlpha
    trimPathStart
    trimPathOffset
    <clip-path>pathData
    *

    * Below is an example of a VectorDrawable defined in vectordrawable.xml. This VectorDrawable is * referred to by its file name (not including file suffix) in the @@ -118,9 +186,8 @@ import java.util.ArrayList; *
  • XML for AnimatedVectorDrawable

    *

    * An AnimatedVectorDrawable element has a VectorDrawable attribute, and one or more target - * element(s). The target elements can be the path or group to be animated. Each target element - * contains a name attribute that references a property (of a path or a group) to animate, and an - * animation attribute that points to an ObjectAnimator or an AnimatorSet. + * element(s). The target element can specify its target by android:name attribute, and link the + * target with the proper ObjectAnimator or AnimatorSet by android:animation attribute. *

    * The following code sample defines an AnimatedVectorDrawable. Note that the names refer to the * groups and paths in the VectorDrawable XML above. @@ -173,7 +240,8 @@ import java.util.ArrayList; * merge the XML files from the previous examples into one XML file: *

    *
    - * <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" >
    + * <animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    + *                  xmlns:aapt="http://schemas.android.com/aapt" >
      *     <aapt:attr name="android:drawable">
      *         <vector
      *             android:height="64dp"
    diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
    index 1ca15525c8a1a..d644beeb7d37f 100644
    --- a/graphics/java/android/graphics/drawable/VectorDrawable.java
    +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
    @@ -76,36 +76,27 @@ import dalvik.system.VMRuntime;
      * 
    *
    android:name
    *
    Defines the name of this vector drawable.
    - *
    Animatable : No.
    *
    android:width
    *
    Used to define the intrinsic width of the drawable. * This support all the dimension units, normally specified with dp.
    - *
    Animatable : No.
    *
    android:height
    *
    Used to define the intrinsic height the drawable. * This support all the dimension units, normally specified with dp.
    - *
    Animatable : No.
    *
    android:viewportWidth
    *
    Used to define the width of the viewport space. Viewport is basically * the virtual canvas where the paths are drawn on.
    - *
    Animatable : No.
    *
    android:viewportHeight
    *
    Used to define the height of the viewport space. Viewport is basically * the virtual canvas where the paths are drawn on.
    - *
    Animatable : No.
    *
    android:tint
    *
    The color to apply to the drawable as a tint. By default, no tint is applied.
    - *
    Animatable : No.
    *
    android:tintMode
    - *
    The Porter-Duff blending mode for the tint color. The default value is src_in.
    - *
    Animatable : No.
    + *
    The Porter-Duff blending mode for the tint color. Default is src_in.
    *
    android:autoMirrored
    *
    Indicates if the drawable needs to be mirrored when its layout direction is - * RTL (right-to-left).
    - *
    Animatable : No.
    + * RTL (right-to-left). Default is false. *
    android:alpha
    - *
    The opacity of this drawable.
    - *
    Animatable : Yes.
    + *
    The opacity of this drawable. Default is 1.0.
    *
    * * @@ -117,32 +108,24 @@ import dalvik.system.VMRuntime; *
    *
    android:name
    *
    Defines the name of the group.
    - *
    Animatable : No.
    *
    android:rotation
    - *
    The degrees of rotation of the group.
    - *
    Animatable : Yes.
    + *
    The degrees of rotation of the group. Default is 0.
    *
    android:pivotX
    *
    The X coordinate of the pivot for the scale and rotation of the group. - * This is defined in the viewport space.
    - *
    Animatable : Yes.
    + * This is defined in the viewport space. Default is 0. *
    android:pivotY
    *
    The Y coordinate of the pivot for the scale and rotation of the group. - * This is defined in the viewport space.
    - *
    Animatable : Yes.
    + * This is defined in the viewport space. Default is 0. *
    android:scaleX
    - *
    The amount of scale on the X Coordinate.
    - *
    Animatable : Yes.
    + *
    The amount of scale on the X Coordinate. Default is 1.
    *
    android:scaleY
    - *
    The amount of scale on the Y coordinate.
    - *
    Animatable : Yes.
    + *
    The amount of scale on the Y coordinate. Default is 1.
    *
    android:translateX
    *
    The amount of translation on the X coordinate. - * This is defined in the viewport space.
    - *
    Animatable : Yes.
    + * This is defined in the viewport space. Default is 0. *
    android:translateY
    *
    The amount of translation on the Y coordinate. - * This is defined in the viewport space.
    - *
    Animatable : Yes.
    + * This is defined in the viewport space. Default is 0. *
    * * @@ -152,58 +135,44 @@ import dalvik.system.VMRuntime; *
    *
    android:name
    *
    Defines the name of the path.
    - *
    Animatable : No.
    *
    android:pathData
    *
    Defines path data using exactly same format as "d" attribute * in the SVG's path data. This is defined in the viewport space.
    - *
    Animatable : Yes.
    *
    android:fillColor
    *
    Specifies the color used to fill the path. May be a color or, for SDK 24+, a color state list * or a gradient color (See {@link android.R.styleable#GradientColor} * and {@link android.R.styleable#GradientColorItem}). * If this property is animated, any value set by the animation will override the original value. * No path fill is drawn if this property is not specified.
    - *
    Animatable : Yes.
    *
    android:strokeColor
    *
    Specifies the color used to draw the path outline. May be a color or, for SDK 24+, a color * state list or a gradient color (See {@link android.R.styleable#GradientColor} * and {@link android.R.styleable#GradientColorItem}). * If this property is animated, any value set by the animation will override the original value. * No path outline is drawn if this property is not specified.
    - *
    Animatable : Yes.
    *
    android:strokeWidth
    - *
    The width a path stroke.
    - *
    Animatable : Yes.
    + *
    The width a path stroke. Default is 0.
    *
    android:strokeAlpha
    - *
    The opacity of a path stroke.
    - *
    Animatable : Yes.
    + *
    The opacity of a path stroke. Default is 1.
    *
    android:fillAlpha
    - *
    The opacity to fill the path with.
    - *
    Animatable : Yes.
    + *
    The opacity to fill the path with. Default is 1.
    *
    android:trimPathStart
    - *
    The fraction of the path to trim from the start, in the range from 0 to 1.
    - *
    Animatable : Yes.
    + *
    The fraction of the path to trim from the start, in the range from 0 to 1. Default is 0.
    *
    android:trimPathEnd
    - *
    The fraction of the path to trim from the end, in the range from 0 to 1.
    - *
    Animatable : Yes.
    + *
    The fraction of the path to trim from the end, in the range from 0 to 1. Default is 1.
    *
    android:trimPathOffset
    *
    Shift trim region (allows showed region to include the start and end), in the range - * from 0 to 1.
    - *
    Animatable : Yes.
    + * from 0 to 1. Default is 0. *
    android:strokeLineCap
    - *
    Sets the linecap for a stroked path: butt, round, square.
    - *
    Animatable : No.
    + *
    Sets the linecap for a stroked path: butt, round, square. Default is butt.
    *
    android:strokeLineJoin
    - *
    Sets the lineJoin for a stroked path: miter,round,bevel.
    - *
    Animatable : No.
    + *
    Sets the lineJoin for a stroked path: miter,round,bevel. Default is miter.
    *
    android:strokeMiterLimit
    - *
    Sets the Miter limit for a stroked path.
    - *
    Animatable : No.
    + *
    Sets the Miter limit for a stroked path. Default is 4.
    *
    android:fillType
    - *
    Sets the fillType for a path. The types can be either "evenOdd" or "nonZero". They behave the - * same as SVG's "fill-rule" properties. For more details, see + *
    For SDK 24+, sets the fillType for a path. The types can be either "evenOdd" or "nonZero". They behave the + * same as SVG's "fill-rule" properties. Default is nonZero. For more details, see * FillRuleProperty
    - *
    Animatable : No.
    *
    * *