Loading graphics/java/android/graphics/drawable/VectorDrawable.java +23 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.graphics.Rect; import android.graphics.Region; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; Loading @@ -38,6 +39,7 @@ import com.android.internal.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.IOException; import java.util.ArrayList; Loading Loading @@ -410,6 +412,27 @@ public class VectorDrawable extends Drawable { } } /** @hide */ public static VectorDrawable create(Resources resources, int rid) { try { final XmlPullParser xpp = resources.getXml(rid); final AttributeSet attrs = Xml.asAttributeSet(xpp); final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); final VectorDrawable drawable = new VectorDrawable(); drawable.inflate(resources, xpp, attrs); drawable.setAnimationFraction(0); return drawable; } catch (XmlPullParserException e) { Log.e(LOGTAG, "parser error", e); } catch (IOException e) { Log.e(LOGTAG, "parser error", e); } return null; } private VAnimatedPath inflateInternal(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { final VAnimatedPath animatedPath = new VAnimatedPath(); Loading tests/VectorDrawableTest/res/drawable/vector_drawable01.xml +7 −7 Original line number Diff line number Diff line Loading @@ -28,14 +28,14 @@ <path android:name="check" android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z" android:fill="?attr/colorControlActivated" /> android:fill="?android:attr/colorControlActivated" /> </group> <group> <path android:name="box1" android:pathData="m127,171l37,38l33,-31l-37,-40l-1,3l-2,0l-30,30z" android:fill="?attr/colorControlActivated" android:stroke="?attr/colorControlActivated" android:fill="?android:attr/colorControlActivated" android:stroke="?android:attr/colorControlActivated" android:strokeLineCap="round" android:strokeLineJoin="round" /> </group> Loading @@ -46,8 +46,8 @@ android:rotation="46.757" android:pivotX="162" android:pivotY="173.5" android:fill="?attr/colorControlNormal" android:stroke="?attr/colorControlNormal" android:fill="?android:attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="3" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading @@ -56,7 +56,7 @@ <path android:name="box3" android:pathData="m187,147l-1,55l-49,-1l2,-53l48,0z" android:stroke="?attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="10" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading @@ -65,7 +65,7 @@ <path android:name="box4" android:pathData="m248,74l0,164l-177,0l1,-165l173,-1l3,2z" android:stroke="?attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="30" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading Loading
graphics/java/android/graphics/drawable/VectorDrawable.java +23 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.graphics.Rect; import android.graphics.Region; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; Loading @@ -38,6 +39,7 @@ import com.android.internal.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.IOException; import java.util.ArrayList; Loading Loading @@ -410,6 +412,27 @@ public class VectorDrawable extends Drawable { } } /** @hide */ public static VectorDrawable create(Resources resources, int rid) { try { final XmlPullParser xpp = resources.getXml(rid); final AttributeSet attrs = Xml.asAttributeSet(xpp); final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); final VectorDrawable drawable = new VectorDrawable(); drawable.inflate(resources, xpp, attrs); drawable.setAnimationFraction(0); return drawable; } catch (XmlPullParserException e) { Log.e(LOGTAG, "parser error", e); } catch (IOException e) { Log.e(LOGTAG, "parser error", e); } return null; } private VAnimatedPath inflateInternal(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { final VAnimatedPath animatedPath = new VAnimatedPath(); Loading
tests/VectorDrawableTest/res/drawable/vector_drawable01.xml +7 −7 Original line number Diff line number Diff line Loading @@ -28,14 +28,14 @@ <path android:name="check" android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z" android:fill="?attr/colorControlActivated" /> android:fill="?android:attr/colorControlActivated" /> </group> <group> <path android:name="box1" android:pathData="m127,171l37,38l33,-31l-37,-40l-1,3l-2,0l-30,30z" android:fill="?attr/colorControlActivated" android:stroke="?attr/colorControlActivated" android:fill="?android:attr/colorControlActivated" android:stroke="?android:attr/colorControlActivated" android:strokeLineCap="round" android:strokeLineJoin="round" /> </group> Loading @@ -46,8 +46,8 @@ android:rotation="46.757" android:pivotX="162" android:pivotY="173.5" android:fill="?attr/colorControlNormal" android:stroke="?attr/colorControlNormal" android:fill="?android:attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="3" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading @@ -56,7 +56,7 @@ <path android:name="box3" android:pathData="m187,147l-1,55l-49,-1l2,-53l48,0z" android:stroke="?attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="10" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading @@ -65,7 +65,7 @@ <path android:name="box4" android:pathData="m248,74l0,164l-177,0l1,-165l173,-1l3,2z" android:stroke="?attr/colorControlNormal" android:stroke="?android:attr/colorControlNormal" android:strokeWidth="30" android:strokeLineCap="round" android:strokeLineJoin="round" /> Loading