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

What are the advantages and disadvantages of using vector drawables compared to using the .png set for Android system icons?

If they are for two different things, what is it?

+7
android png android-image android-drawable
source share
3 answers

A png is a compressed image. It has a fixed size, if you try to make it larger or smaller, it will need to either duplicate or delete data. Too large or too small, and it does not look right (too large is worse than too small).

The output vector is a series of commands that tell how to draw something. These commands are scalable, so a well-executed vector drawing will look just as good at 1000x1000 as it does at 100x100.

The advantage of png is its lightness and relatively fast performance. The selectable vector is slower (you need to execute the commands) and it is more difficult to create a good one. But it scales better. If scaling is not required, it is possible that png is what you want. If so, you may need a vector.

Also note that some types of images work better for vectors than others - the icon is a good use of the vector. Photography will not work.

+3
source share

Vector images reduce the size of your apk since you only have 1 image with several in different folders. They also scale very well, so you only need to create 1 vector drawing

The disadvantage of vectors is that they are a little heavy, so you should use them in several places

+3
source share

In addition to scaling factors and space, with vector drawings, you can reproduce and modify real-time vector information for drawn objects, which means that you can do things like transformations (for example, transforming a figure). With the PNG set, you have a static view, and thatโ€™s all, you canโ€™t play with forms because they are only static bitmaps (unless you are doing anything complicated with them). Check out this path change example to find out what you can get. Remember that with a set of PNG graphic elements you can use flexibility and space with speed, with vector drawings you get flexibility and space, but loss rate (because vector conversions are tasks with heavy processor use - as opposed to scaling a bitmap image).

0
source share

All Articles