menu search more_vert

SVG (Scalable Vector Graphics) in Android Studio

Public on February 4, 2016
It is time consuming to scale the bitmap drawable for different density buckets. To make it easier Google added support for Vector Drawables starting from Lollipop (API level 21). The major advantage of Vector Drawables is that it can be scaled to any size without losing quality. Also you need to provide only one file rather than bitmap for each density buckets. Let us now discuss how to use SVG in android.
You cannot use the .svg file directly. The SVG needs to be converted to corresponding xml file. Starting from Android Studio 1.4 we can use theVector Asset Studio to make the process easier.
Another great news is that the Vector Asset Studio includes all the material design icons, so you do not need to download the icons separately.

Steps

1. Right click on the drawable folder select New -> Vector Asset
2. The Vector Asset Studio provides you option to select the inbuilt Material icons or your own local svg file. You can override the default size if needed.
3. Then Next and Finish. You are done.
You can use this, similar to the normal drawable PNG in layouts.
Enjoy Coding :)




[Advertising]Faster Thinking - Speed up your brain


Faster Thinking Game



sentiment_satisfied Emoticon

expand_less