Amit
Amit

Reputation: 3712

Android - What's the advantage of using vector drawables in the app supporting minimum API level 20 or lesser?

I am using support library for vector drawables in my app as below and minSdkVersion is 16.

android {  
    defaultConfig {  
        vectorDrawables.useSupportLibrary = true  
    }  
}

As per the official documentation here, it suggests two approaches to deliver the app on the play store.

If I go with first approach which says: Create one APK that includes both the vector drawables and the corresponding raster representations. This solution is the simplest to implement.

Does it have any advantage? As it includes both vector drawables and raster representation. Is it not increasing the apk size?

Upvotes: 3

Views: 3929

Answers (1)

David Medenjak
David Medenjak

Reputation: 34552

Most importantly: Test it.

Get an emulator for at least your target sdk and min sdk and see if the app crashed or not, because with Vector Drawables and Support library there are some pitfalls.

Why use Vectors?

They can be scaled.

Whether you draw the drawable with the intended 24dp or scale it up to 100dp, it always looks fine. If you try the same thing with a bitmap, not so much.

Another thing is that they will drastically reduce your apk size, since they are in most cases smaller than rasterized images.

The drawback is that they might take longer to draw, etc since there's more of parsing and drawing going on than just using a bitmap. This should although be neglectable if you keep your vectors simple.

Also read about using vector drawables with the support library.

Why not use vectors?

Other than the (possible) performance impact mentioned above, you might have to fix a few things like vectors within layer-list drawables and such, as support for those can be enabled but it is not recommended. Also it will not work for things like the window background on lower API versions, so if you do a splash screen by using the window background you might still want to use bitmaps only.


I personally use Vector Drawables wherever possible. It is especially useful if you want to modify colors or fix some stuff, as you can just modify the xml, and you don't have to get a new graphic export.

Upvotes: 7

Related Questions