Convert Vector Drawable to SVG - android

Is there any tool to convert Vector Drawable to SVG? I lost my original svg file and now I would like to reduce the size of the image. Currently, I have,
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1200dp"
android:height="1200dp"
android:viewportHeight="1200"
android:viewportWidth="1200">
I would like to make it 180x180. Thanks in advance.

Look at this Shapeshifter
Shapeshifter tool can import VectorDrawable XML file and export back to SVG file

Have a look at this Convert VectorDrawable to SVG
The Vector Drawable format is pretty similar to SVG. With just a few modifications you can turn your xml drawable back to SVG
Credits to this guy who made this python script that coverts xml drawables back to SVG https://gitlab.com/Hyperion777/VectorDrawable2Svg

Related

Why I can't add an .svg file with effects such as drop shadows, blurs, and color matrix in Android Studio?

Why I can't add an .svg file with effects such as drop shadows, blurs, and color matrix as a drawable resource in Android Studio?
Because Android's drawables are not SVG. You can create xml drawables fron SVGs. The format of Android's vector drawablea is similar to SVG, but it is not the same.
If you want all the effects you mentioned, you'll probably have to create bitmap images in various resolutions in a graphics program that fully supports SVG and use those bitmap images (PNG for instance) for your app, putting them in the correct drawables folders.

how do you use svg in drawable folder?

i am creating a bottom navigation bar for a android app following this guide
however, when using svg in android:icon and building it, it shows a error
Error: The file name must end with .xml or .png
i found out that i needed to move the svg to the assets folder. but if i move it, i can't use the svg... any help is much appreciated, thank you
The answer above gives a link to convert pictures from SVG to XML, but this tool is not for free(only for one SVG file)
So why not to use ANDROID build-in tool?
The best way is to go to res-> drawable-> Vector Asset -> Local file (SVG, PSD) ->select your SVG file from the place you save it.
and you are done :)
Android uses vector drawables which are xml files rather than SVG's.
You will have to convert the SVG to a vector drawable. Many ways of doing it but a handy web tool is available here.
It won't do complex SVG's but copes with the majority.

How can you convert an existing resource/drawable/xml file to an Icon?

Ive a resource/drawable/xml file that I'd like to use as my app icon. Can this be done, if so, how do you do it.
thanks,
Jim
yes you can ,
and if you want to convert the png file to xml you can convert png to vector xml online and convert png to vector xml with any online tool.

How do I export Android XML vector drawables to another format?

I want to recreate my app for iOS and the icons in Android are XML vectors with the "android:pathData" attribute. How do I convert these to an image that I can place into Xcode and use (preserving transparency)?
I have searched for a solution and found nothing and read the article on the Android Developer site on Vector Asset Studio but found nothing about exporting these drawables to something I can import into Xcode.
I did it by creating an SVG file and copying the value of the pathData attribute of the path element in the XML file and pasting it into the d attribute of the path element in the SVG file. I then converted it to PNG using ImageMagick.
So
<path android:pathData="[Path Data]">
becomes
<path d="[Path Data]">.
Then
convert -background none image.svg image.png
in the command line.
If there is a better way of doing this please post it.
After using the trick Questioner provide, I use a browser to open the svg file, zoom-in to the size as big as possible and take a screenshot. FYI.

SVG image not display

i have converted a psd file into svg, it works good at browser but not works on android native applications, how can i do this?
ImageView imageView = (ImageView)findViewById(R.id.img1);
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
//Parse the SVG file from the resource
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
//Get a drawable from the parsed SVG and apply to ImageView
imageView.setImageDrawable(svg.createPictureDrawable());
This is the code i used to display svg image. it works when i used simple svg images, but it not works converted svg images using illustrator . how can i do?
I am guessing that your SVG just contains the image from the PSD. Is that the case?
If all that the SVG contains is a bitmap image, then you are not really using SVGs for their proper purpose (vector art). You would be better off just converting the PSD to a JPEG or PNG and loading that into an ImageView.
However, if you are definitely sure you want to load an SVG, then the solution depends on which SVG library you are using.
svg-android: As far as I know, it doesn't support <image> elements, so there is no solution
AndroidSVG: supports <image>, so it should work as long as the device has the memory to load the image. If the image is embedded in the file, you should be fine. If it references an external image, you will need to pass in an SVGExternalFileResolver so it knows how to find the bitmap. See my answer to the following question: https://stackoverflow.com/a/21531168/1292848

Categories

Resources