Search code examples
androidxmlandroid-studiosvgandroid-vectordrawable

SVG not correctly converting to an XML Drawable with a high viewport in Android Studio


I have the SVG here: https://github.com/Tick-Talk/tick-talk.github.io/blob/master/ticktalk-logo.svg

In Android Studio,I right click drawables, new -> vector asset, keep the size as is (as it is already 108dp, the size I need for the app icon), and then import. The resulting XML Drawable is completely incorrect and displays in both android studio and on my phone incorrectly.

Am I doing something wrong, or is this a bug when dealing with high viewport dimensions (the svg has almost 3000 pixels for both dimensions) in Android Studio?

And how can I properly convert this SVG to an XML format without the weird issue I am facing?

Thanks in advance!


Solution

  • The Android vector drawable specification does not support all features of SVG unfortunately. That being said, there are some other online tools you can use to convert SVG to XML, and they usually are pretty good about converting features that are not supported.

    This one does a good job of telling you what is not supported, and it can give you some options to try to correct the issues. For example, for your icon, it reports the following:

    Warning #1: found clip-path(s) attribute which is not fully supported yet (try enabling support for clip-path below)

    Warning #2: stroke-width not found on path one or more times. Defaulting all instances to 1.

    It also shows you the converted code.

    This one converts, shows the converted code, and shows a preview of your graphic.