What is the difference between using vector drawable and a set of .png for icons in Android? What is the difference between using vector drawable and a set of .png for icons in Android? android android

What is the difference between using vector drawable and a set of .png for icons in Android?


A png is a compressed image. It has a fixed size, if you try to make it bigger or smaller it will need to either duplicate or remove data. Too big or too small and it doesn't look right (too big is worse than too small).

A vector drawable is a series of commands that tell it how to draw something. These commands scale, so a well executed vector drawable will look as good at 1000x1000 as it does at 100x100.

The advantage of a png is its easy to do and relatively fast performance. A vector drawable is slower (you have to execute the commands) and harder to create a good one. But it scales better. If scaling isn't needed, a png is probably what you want. If it is, you may want a vector.

Also note some kinds of images work better for vectors than others- an icon is a good use of a vector. A photograph wouldn't work.


Vector drawables reduce the size of your apk since you only have 1 Image vs having multiple in different folders. They also scale very well which is why you only need to create 1 vector drawable

The downside to vectors are that they are a little performance heavy so you should use them in a few places


Aside from the scaling and space factors, with vector drawables you can play and modify in realtime the vector information of the drawables, that means that you can do things like transformations for example (like morphing a figure). With a set of PNGs you have a static representation and that's all, you cannot play with the forms because they are only static bitmaps (unless you do tricky things with them). Check out this example of path morphing in order to know what you can get. Remember, with a set of PNG drawables you trade flexibility and space with speed, with vector drawables you gain flexibility and space, but loss speed (because vector transformations are CPU intensive tasks -in contrast to bitmap scaling-).