Home > other >  Convert SVG with filters to Android Vector Drawable
Convert SVG with filters to Android Vector Drawable

Time:10-19

I need to convert SVG file which contains filter tags, which usually consists of fe* tags. (feFlood, feGaussianBlur,...) Android Asset Studio and other instruments can not deal with it, and the only thing that came to me was using gradient in vector drawable, but it fits only to linearGradient in SVG. For example, Asset Studio can't convert this code

<svg width="230" height="120"
 xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink">

 <filter id="blurMe">
    <feGaussianBlur in="SourceGraphic" stdDeviation="5" />
 </filter>

 <circle cx="60"  cy="60" r="50" fill="green" />

 <circle cx="170" cy="60" r="50" fill="green"
      filter="url(#blurMe)" />
</svg>

Can someone give algo for converting such tags if it is real?

CodePudding user response:

<filter> and <feGuaussianBlur> are SVG filter elements. They add bitmap filter effects to SVG elements.

Android VectorDrawables does not support SVG filters.

If you can live without the filter effect (the blur), then edit your SVG file and remove it/them. Then try importing again.

If you need the blur effect, then you won't be able to use a VectorDrawable. You will be forced to use a bitmap image instead.

  • Related