This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

does this apply even if my activity is based on AppCompatActivity? AppCompatActivity already uses AppCompatDelegate.
– ThuptenNov 5 '16 at 20:32

Simply use AppCompatImageView instead of ImageView. Problem solved. No need to keep pngs for lower versions. Even srcCompat is not needed.
– Harish GyananiDec 22 '16 at 5:45

I've done steps 1 to 3 (on the 3rd step used app:srcCompat). However, I still see an exception XmlPullParserException: Binary XML file line #4: invalid drawable tag vector. It looks like the vector tag in the XML is not recognized on this KitKat device ?
– Someone SomewhereOct 5 '17 at 14:22

Support for vector drawables in places like android:drawableLeft was disabled in support library 23.3. It was announced on Google+:

we’ve decided to remove the functionality which let you use vector
drawables from resources on pre-Lollipop devices due to issues found
in the implementation in version 23.2.0/23.2.1. Using app:srcCompat and setImageResource()
continues to work.

This doesn't work. Use one of the other answers here instead.
– SakiboyMay 9 '17 at 0:46

you should have this vectorDrawables.useSupportLibrary = true on your build.gradle and this AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); on your onCreate of your Application Class or {AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } on your activity. Check the question. He added those lines on his code before he ask
– jmarkstarMay 9 '17 at 15:22

`VectorDrawable` and `AnimatedVectorDrawable` in this support library can be inflated in this way:

Calling static getDrawable() methods:

//This will only inflate a drawable with <vector> as the root element
VectorDrawable.getDrawable(context, R.drawable.ic_arrow_vector);
//This will only inflate a drawable with <animated-vector> as the root element
AnimatedVectorDrawable.getDrawable(context, R.drawable.ic_arrow_to_menu_animated_vector);
// This will inflate any drawable and will auto-fallback to the lollipop implementation on api 21+ devices
ResourcesCompat.getDrawable(context, R.drawable.any_drawable);

If inflating the Drawable in java code, it is recommended to always use ResourcesCompat.getDrawable() as this handles Lollipop fallback when applicable. This allows the system to cache Drawable ConstantState and hence is more efficient.
The library has the following morph (bi-directional) animations :

Look at the github README for vector-compat here: https://github.com/wnafee/vector-compat
This will fix your problem (down to API 14) if you merge it with your app module's build.gradledependencies (usually at the end of file):