Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does android have *native* support SVG image as drawable resources (icons)?

I'm reading and watching UI tutorial. They all talk about the fact that you need to be aware of different devices size and resolution. Therefore export your icons into several size to support different screen density. SVG is an open standard (W3C) that should be use to tackle this kind of problem. So can I natively use SVG file as drawable for my icons ?

N.B.: I'm NOT talking about browser support.

like image 509
Édouard Lopez Avatar asked Jul 12 '11 16:07

Édouard Lopez


People also ask

Can we use SVG in drawable Android?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.

Can I use SVG for Android app icon?

Use of SVG Image: Recommended or Not Using SVG images in an Android application can be extremely complicated. That is why so many designers recommend that you don't do it. There are so many other ways in which SVG images can be used more effectively.

Can I use SVG as background image in Android?

SVG images can be used as background-image in CSS as well, just like PNG, JPG, or GIF. All the same awesomeness of SVG comes along for the ride, like flexibility while retaining sharpness. Plus you can do anything a raster graphic can do, like repeat.


2 Answers

Android does not support SVG rasterization. Look at libsvg-android or svg4mobile. It solves that problem.

like image 119
Delimitry Avatar answered Sep 24 '22 03:09

Delimitry


The answer has changed. Since version 21, Lollipop the operating system has had support for VectorDrawable. This is added to by a support library that allows you to use VectorDrawable well back into previous versions. These include support for importing most of the important SVG vector commands and having Android Studio automatically convert them to a VectorDrawable.

Use Vector Image Assets for all versions. -- Also even in older versions it's entirely possible to do fonts. Basically you give it a font asset then load up a specific letter of the font as an icon. Since fonts are glyphs and vector glyphs at that, you can very much get vector icons pretty far back.

https://fortawesome.github.io/Font-Awesome/icons/

like image 29
Tatarize Avatar answered Sep 22 '22 03:09

Tatarize