本文介绍了Android Studio 1.3 SVG到png转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最近的Google IO 2015中,Google宣布新的Android Studio 1.3/新的gradle插件将支持导入和SVG文件,并且构建系统将针对不同的设备密度(hdpi,xhdpi,xxhdpi等)生成资产:

In recent google IO 2015, google announced that the new Android Studio 1.3/ new gradle plugin will have support for importing and SVG file and the build system will generate the assets for different device densities (hdpi, xhdpi, xxhdpi etc):

http://robovm.com/google-io-summary-Whats-new-in-android-development-tools/ https://www.youtube.com/watch? v = f7ihSQ44WO0& feature = youtu.be& t = 2m46s

不幸的是,似乎没有更多有关如何实现该目标的信息.还有人有更多细节吗?

Unfortunately there doesnt seem to be more information about how to achieve that. Does any one have any more details about it?

在中有一些提及: Android:在res中使用SVG会导致错误:文件名必须以.xml或.png结尾"

,我试图创建一个hello world应用程序,并将一个svg文件(在可绘制文件夹中将其重命名为xml).它编译并安装在设备上,但在执行过程中崩溃,并说svg不是vlaid标记.假设原始文件需要更多的转换.

and I tried to create a hello world app and places an svg file (renamed it to xml in the drawable folder). it compiled and installed on the device, but crashed during execution saying svg is not a vlaid tag. suppose the original file needs more conversion.

推荐答案

要添加新的矢量资产,请在Android Studio中右键单击可绘制文件夹,然后选择新建">矢量资产".请注意,您需要Gradle 1.4或更高版本,才能将矢量资产用于构建目标低于21的项目.在这种情况下,Gradle将在构建时将矢量图像转换为PNG.

To add a new vector asset right click on your drawable folder in Android Studio and choose New > Vector asset. Please note that you need Gradle 1.4 or newer to use vector assets with projects with a build target lower than 21. In this case Gradle will convert the vector images to PNGs at build time.

当前的Gradle 1.4 Beta版本在发布apk时打开密钥库存在一些问题,因此在导入大量矢量图像之前,请尝试首先发布您的应用程序(这只是我对Gradle 1.4.0-beta6的个人经验,Gradle将报告遭到篡改的密钥库,例如,请参见)

The current beta version of Gradle 1.4 has some issues with opening keystores when releasing an apk, so before importing a lot of vector images, try to release your app first (this is only my personal experience with Gradle 1.4.0-beta6, Gradle will report a tampered keystore, e.g. see here)

这篇关于Android Studio 1.3 SVG到png转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:43