From d64255f61db30934e293adab2a5a8ac9eeea0b98 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Tue, 26 Jul 2016 14:36:20 -0700 Subject: [PATCH] Update the javaDoc for VectorDrawable and AnimatedVectorDrawable b/30269243 Change-Id: I139a3fcac95c41a667fa06aa3223b812caad6243 (cherry picked from commit c224417511d8179a08c4dfd4badc73dd9699ebf2) --- .../drawable/AnimatedVectorDrawable.java | 49 +++++++++++++++++++ .../graphics/drawable/VectorDrawable.java | 40 ++++++++++++--- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java index c836204486b05..0f305f3cff3d2 100644 --- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java @@ -144,6 +144,55 @@ import java.util.ArrayList; * android:valueType="pathType"/> * </set> * + *

+ * Since AAPT tool is now supporting a new format which can bundle several related XML files into + * one, we can merge the previous example into one XML file, like this: + *

+ *
+ * <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" >
+ *     <aapt:attr name="android:drawable">
+ *         <vector
+ *             android:height="64dp"
+ *             android:width="64dp"
+ *             android:viewportHeight="600"
+ *             android:viewportWidth="600" >
+ *             <group
+ *                 android:name="rotationGroup"
+ *                 android:pivotX="300.0"
+ *                 android:pivotY="300.0"
+ *                 android:rotation="45.0" >
+ *                 <path
+ *                     android:name="v"
+ *                     android:fillColor="#000000"
+ *                     android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
+ *             </group>
+ *         </vector>
+ *     </aapt:attr>
+ *
+ *     <target android:name="rotationGroup"> *
+ *         <aapt:attr name="android:animation">
+ *             <objectAnimator
+ *             android:duration="6000"
+ *             android:propertyName="rotation"
+ *             android:valueFrom="0"
+ *             android:valueTo="360" />
+ *         </aapt:attr>
+ *     </target>
+ *
+ *     <target android:name="v" >
+ *         <aapt:attr name="android:animation">
+ *             <set>
+ *                 <objectAnimator
+ *                     android:duration="3000"
+ *                     android:propertyName="pathData"
+ *                     android:valueFrom="M300,70 l 0,-70 70,70 0,0   -70,70z"
+ *                     android:valueTo="M300,70 l 0,-70 70,0  0,140 -70,0 z"
+ *                     android:valueType="pathType"/>
+ *             </set>
+ *         </aapt:attr>
+ *      </target>
+ * </animated-vector>
+ * 
* * @attr ref android.R.styleable#AnimatedVectorDrawable_drawable * @attr ref android.R.styleable#AnimatedVectorDrawableTarget_name diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index dc1d18f3b2bda..9ff69650294dd 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -27,9 +27,9 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Insets; import android.graphics.PixelFormat; +import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; -import android.graphics.PorterDuff.Mode; import android.graphics.Shader; import android.util.ArrayMap; import android.util.AttributeSet; @@ -140,12 +140,16 @@ import dalvik.system.VMRuntime; * in the SVG's path data. This is defined in the viewport space. *
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. 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.
+ * 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. *
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. 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.
+ * 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. *
android:strokeWidth
*
The width a path stroke.
*
android:strokeAlpha
@@ -166,8 +170,9 @@ import dalvik.system.VMRuntime; *
android:strokeMiterLimit
*
Sets the Miter limit for a stroked path.
*
android:fillType
- *
Sets the fillType for a path. It is the same as SVG's "fill-rule" properties. - * For more details, see https://www.w3.org/TR/SVG/painting.html#FillRuleProperty
+ *
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 + * FillRuleProperty
* * * @@ -201,7 +206,26 @@ import dalvik.system.VMRuntime; * android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> * </group> * </vector> - * + * + * + *
  • And here is an example of linear gradient color, which is supported in SDK 24+. + * See more details in {@link android.R.styleable#GradientColor} and + * {@link android.R.styleable#GradientColorItem}. + *
    + * <gradient xmlns:android="http://schemas.android.com/apk/res/android"
    + *     android:angle="90"
    + *     android:startColor="?android:attr/colorPrimary"
    + *     android:endColor="?android:attr/colorControlActivated"
    + *     android:centerColor="#f00"
    + *     android:startX="0"
    + *     android:startY="0"
    + *     android:endX="100"
    + *     android:endY="100"
    + *     android:type="linear">
    + * </gradient>
    + * 
    + *
  • + * */ public class VectorDrawable extends Drawable {