I've seen the android developers blog that the new design support library 23.2 supports animated vector. When i searched i came across this link to implement animated vector drawable. Is it the same way to implement animated vector drawables in design support library 23.2? Can someone help me out with the new implementation?
Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.
AndroidSVG is a SVG parser and renderer for Android. It has almost complete support for the static visual elements of the SVG 1.1 and SVG 1.2 Tiny specifications (except for filters).
Here's a link to an example project on Github implementing the Support Library to make this Floating Action Button.
Using the Support Library is very similar to the non-Support Library method in that the xml files for AnimatedVectorDrawables are the same, as are the objectAnimators and static VectorDrawables.
The differences come when setting up your project to use the Support Library and when referring to the AnimatedVectorDrawables in your code.
Make sure you are using at least version 23.2.0 of AppCompat in your build.gradle, the VectorDrawable and AnimatedVectorDrawable libraries do not need to be added separately:
dependencies {
...
...
compile 'com.android.support:appcompat-v7:23.2.0'
}
The official anouncement blog you linked to gives a couple of different ways to ensure Android Studio does not convert your Vector Drawables into pngs. There are two different methods depending on what version of the Gradle plugin you are using, so you should follow the appropriate one.
To call up an Animated Vector from resources in your code:
AnimatedVectorDrawableCompat animatedVector = AnimatedVectorDrawableCompat.create(this, R.drawable.animated_vector_name);
You can display this on ImageViews, Buttons etc. with their .setImageDrawable(animatedVector);
method, and start the animation using animatedVector.start();
Important note: as mentioned in Chris Banes' post, there are some limitations to what will work in the support library. The sqisland.com post you linked to includes examples of Path Morphing, which won't work with the current support library(version 23.2.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With