简体   繁体   English

有没有办法使用 Android Asset Studio 批量转换 svg 文件?

[英]Is there a way to bulk convert svg files using Android Asset Studio?

I have a large number of svg files I want to convert to xml vector assets for Android.我有大量的 svg 文件要转换为 Android 的 xml 矢量资产。

The documented process is, for each file, File->New->Vector Asset.记录的过程是,对于每个文件,File->New->Vector Asset。 Then choose the svg file, click Next then Finish.然后选择 svg 文件,单击 Next 然后单击 Finish。

Is there a faster way?有没有更快的方法? Maybe a bash comment to launch Asset Studio?也许是启动 Asset Studio 的 bash 评论?

The Resource Manager tool that was added in Android Studio version 3.4 can bulk import SVGs and convert them into vector drawables. Android Studio 3.4 版中添加的资源管理器工具可以批量导入 SVG 并将其转换为矢量可绘制对象。

  1. ToolsResource Manager ToolsResource Manager
  2. Select the Drawable tab选择Drawable选项卡
  3. Click the + button in the top left corner单击左上角的+按钮
  4. Select Import Drawables选择Import Drawables

There you can select all the files you want to import at once.在那里您可以一次选择要导入的所有文件。 More details here .更多细节在这里

There are few Git projects which would help you achieve the bulk conversion of svg files to Vector Drawable supported by android.很少有 Git 项目可以帮助您将 svg 文件批量转换为 Android 支持的 Vector Drawable。

  1. Juraj Novák's : http://inloop.github.io/svg2android/ Juraj Novák 的: http : //inloop.github.io/svg2android/

  2. SvgToVectorDrawableConverter original repo was deleted.SvgToVectorDrawableConverter原始存储库已删除。 But you could choose one of the fork .但是你可以选择其中一个叉子 Example: svg2vd -i "\\*" -o out --fix-fill-type示例: svg2vd -i "\\*" -o out --fix-fill-type

  3. For single conversion: SVG to Vector Drawable Convertor online单次转换: SVG to Vector Drawable Converter Online

  4. Use wrapper of original converter ported from Android Studio使用从 Android Studio 移植的原始转换器的包装器

Hope it helps!希望能帮助到你!

下载这个 jar 文件并像下面的例子一样使用它

java -jar C:\Users\dan\Downloads\Svg2VectorAndroid-1.0.jar C:\Users\dan\Desktop\svgs_dir

Keep Svg2VectorAndroid.jar and the folder that having all the Svg file in same folder and then open cmd and go to that folder path where you put your jar and source folder and then execute the commandSvg2VectorAndroid.jar和包含所有 Svg 文件的文件夹保存在同一文件夹中,然后打开cmd并转到放置 jar 和源文件夹的文件夹路径,然后执行命令

java -jar Svg2VectorAndroid.jar <source folder name>

and press enter.并按回车键。 Now you can get your all xml file in source folder with folder name ProcessedSVG .现在您可以在源文件夹中获取所有 xml 文件,文件夹名称为ProcessedSVG

Hope it helps.希望能帮助到你。

Use this link, it's really helpful : https://svg2vector.com/使用此链接,它真的很有帮助: https : //svg2vector.com/

Just upload your svg file (you can select multiple files) and download all drawable files.只需上传您的 svg 文件(您可以选择多个文件)并下载所有可绘制文件。 Just copy to your Drawable project file and viola!只需复制到您的 Drawable 项目文件和中提琴即可!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android studio 生成资产文件 - Android studio generating asset files 如何将SVG转换为Android的矢量资产 - How to convert svg to vector asset for android SVG 文件在 Android Studio 中是否可扩展 - Are SVG files scalable in Android Studio Android Vector Asset Studio:导入 SVG 并使用 ID 作为名称 - Android Vector Asset Studio: Import SVG and use ID as Name 为什么在资产导入时 SVG 文件中的文本属性没有出现在 Android Studio 矢量资产 XML 中 - Why text attribute in SVG file does not appear in Android Studio vector asset XML on asset import SVG 文本消失了,当使用包含 Android Studio 中的文本的 SVG 创建资产时 - SVG text is gone, when creating asset with SVG which contains a text in Android Studio 导入具有两个动画文件的Scenform资产后,Android Studio崩溃 - Android Studio crashes after importing Scenform asset with two animation files 通过ID或名称android studio访问资产子文件夹下的文件 - Accessing files under asset subfolder by Id or Name android studio 为什么Visual Studio(Xamarin)中的Android资源文件不允许有重音符号? - Why are Android Asset files in Visual Studio (Xamarin) not allowed to have accents? 有没有办法改变Android Asset Studio保存资源的目录? - Is there a way to change the directory to which the Android Asset Studio saves resources?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM