How to set VectorDrawable as an image for ImageView programmatically

If you want to use vector drawables (less OR greater than API 21) just do the following:

Set the image programmatically (e.g. in your activity):


or by XML:


In your app’s build.gradle you need to include:

android {
    defaultConfig {
        vectorDrawables.useSupportLibrary = true

And for vector support for less then API 21, add the following to onCreate:


Leave a Comment