android - 自动转换为 png 的矢量可绘制对象

标签 android vector-graphics android-build android-icons

在 Google IO,工具团队简要展示了定义具有特定后缀(例如 ic_heart_48px.xml)的矢量可绘制对象的可能性,然后将其转换为所有必要密度的 png。不幸的是,除了 IO 记录之外,我没有找到有关此功能的任何文档。

这是构建工具或 Android Studio 的功能吗?假设它是构建工具的一部分,它已经可用了吗?我应该使用哪个版本?我必须明确启用该功能吗?

Google 是否提供 Android xml 矢量格式的素材图标?

最佳答案

使用 Android Studio 1.4 和 Gradle Android 插件到 1.4.0-beta3(或更高版本),只需右键单击项目中的 res/drawable 文件夹并从内容菜单中选择 New → Vector Asset。

enter image description here

可以在 1.4 版的发行说明中看到,该工具还提供向后兼容性。

We are also excited to offer backwards compatibility for your vector assets in Android Studio 1.4. Once you have a vectorDrawable image in your res/drawable, the Gradle plugin will automatically generate raster PNG images for API level 20 and below during build time. This means you only need to update and maintain your vector asset for your app project and Android Studio can take care of image conversion process. Note, it is still best practice to create density dependent launcher icons in your res/mipmap folder.

请注意,尚不完全支持 svg 格式。可能缺少某些功能。

阅读有关此功能的完整博客文章并在此处观看视频:http://android-developers.blogspot.pt/2015/09/android-studio-14.html

关于android - 自动转换为 png 的矢量可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30813667/

相关文章:

java - Java中的形状组合?

安卓工作室 : Error:Execution failed for task ':app:dexDebug'

android - 我如何将消息从一个模拟器发送到特定端口到android中的另一个模拟器?

javascript - AndroidScript - DrawArc 等效吗?

java - Android Studio 无法运行单个类

android - AChartEngine 在轴上方显示 x 轴标签

android - 为什么 Android Asset Studio 会剪切我的矢量图像?

algorithm - 平均矢量图像以获得中间图像

android - 支持 64 位会导致在 build.gradle 中添加 ndk.abiFilters 时出错

android - 使用包含参数的 json 对象改造 POST