Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to use SVG in Android?

I have found a myriad of libraries in order to use svg in Android and avoid the frustrating creation of different resolutions and dropping files for each resolution, this becomes very annoying when the app has many icons or images.

Can anyone be as kind to give a step by step process of the simplest to use library for using SVG in Android, I'm sure this will help many others too.

Also I use Android Studio and Illustrator for generating my icons and images.

like image 495
CommonSenseCode Avatar asked Jun 18 '15 18:06

CommonSenseCode


People also ask

Can Android render SVG?

android-svg supports SVG fairly well. It just doesn't have great support for filters or light sources.

What is the best app to open SVG files?

Adobe Illustrator, known for creating vector-based artwork, natively supports both loading and saving files in SVG format. Also, Inkscape and GIMP are two free programs that can save artwork in SVG format.

What is the best way to use SVG?

SVG images can be written directly into the HTML document using the <svg> </svg> tag. To do this, open the SVG image in VS code or your preferred IDE, copy the code, and paste it inside the <body> element in your HTML document. If you did everything correctly, your webpage should look exactly like the demo below.


1 Answers

First you need to import svg files by following simple steps.

  1. Right click on your project's drawable folder (app/res/drawable)
  2. Click new
  3. Select Vector Asset

If image is available in your computer then select local svg file. After that select the image path and an option to change the size of the image is also available at the right side of dialog if you want to. In this way svg image is imported in your project.

After that for using this image use the same procedure:

@drawable/yourimagename 
like image 50
Pallavi Jain Avatar answered Sep 30 '22 20:09

Pallavi Jain