SVG和Android中的VectorDrawable之间的区别 [英] Difference between SVG and VectorDrawable in Android

查看:127
本文介绍了SVG和Android中的VectorDrawable之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然Android支持SVG,但为什么要将其转换为VectorDrawable?

While Android supports SVG, why should it be converted to VectorDrawable?

此代码示例显示了Android中的SVG:

This code example shows SVG in Android:

SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
imageView.setImageDrawable(svg.createPictureDrawable());

推荐答案

您提到的SVGParser功能是对Android的SVG支持的第三方实现.

The SVGParser functionality you mention is a third party implementation of SVG support for Android.

在Android中使用SVG的主要问题是:

The major problems with using SVG in Android are:

  • SVG文件可能非常复杂,渲染速度可能很慢

  • SVG files may be very complex and can be very slow to render

我使用的所有第三方实现都有错误,无法正确加载或呈现某些SVG文件

All the third party implementations I have used have had bugs and failed to load or render some SVG files correctly

大多数第三方实现已被放弃,没有一个 似乎得到了积极的维护

Most of the third party implementations have been abandoned and none seem to be actively maintained

在下面的文章中,我写了更多有关在Android中使用SVG文件和可用的第三方库的文章:

I have written more about using SVG files in Android and the available third party libraries in the following article:

https://androidbycode .wordpress.com/2015/02/27/vector-graphics-in-android-part-1-svg/

VectorDrawable支持SVG格式的子集,该子集旨在确保快速呈现.我已经撰写了有关VectorDrawable的文章,以及如何将现有的SVG文件转换为VectorDrawable

VectorDrawable supports of subset of SVG format that is designed to ensure it is fast to render. I have written about VectorDrawable and how to convert your existing SVG files to VectorDrawable here.

这篇关于SVG和Android中的VectorDrawable之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆