Skip to content

Convert multiple .svg files to .xml vector drawables for Android

Notifications You must be signed in to change notification settings

eagskunst/Svg2VectorAndroid

 
 

Repository files navigation

Svg2VectorAndroid

Convert multiple .svg files to vector drawables for Android.

This forks servers as minimal enchantment of the original repository. The Google algorithm leaves the default width and height of the served .svg. This could lead to compilation problems where the compiler throws an OutOfMemory exception. Also, for some reason it adds 'pt' to some measures, which also leads to compilation problems. That is why I created a Python script (cleaner.py) that would optimize the files to the minimum required width (200dp) and height and remove the unnecessary 'pt'.

Compiling/Executing

Kotlin/Java project

Install and configure Kotlin in your favorite IDE if you have not.

  • Clone the repository.
  • Open in on your favorite IDE.
  • Configure the program arguments (Eg: Edit configurations -> Program arguments in IntelliJ). The arguments are separated by spaces.
  • Run

You can also change the code in Runner.main to a custom instance of SvgFilesProcessor

Python script

  • Install Python3 on your system if you have not.

  • After running the SvgFilesProcessor, copy the cleaner.py to the directory with the processed files (source/ProcessedSVG by default).

  • Execute the following command while in the directory:

      $ python3 cleaner.py
    

Known issues

  • The Kotlin project needs to be executed two times because in the first one throws a IllegalArgumentException caused by a null value that in fact is not null in any moment.

Plans

  • Fix issues.
  • Migrate Python3 code to Kotlin.
  • Create .jar .
  • Create UI for the process.

About

Convert multiple .svg files to .xml vector drawables for Android

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 80.7%
  • Python 19.3%