Skip to content Skip to sidebar Skip to footer

How To Implement Animated Vector Drawables Using The Design Support Library 23.2?

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 drawa

Solution 1:

Here's a link to an example project on Github implementing the Support Library to make this Floating Action Button.

enter image description here

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:

AnimatedVectorDrawableCompatanimatedVector= 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)

Post a Comment for "How To Implement Animated Vector Drawables Using The Design Support Library 23.2?"