[英]Difference between SVG and VectorDrawable in Android
While Android supports SVG, why should it be converted to VectorDrawable? 虽然Android支持SVG,但为什么要将其转换为VectorDrawable?
This code example shows SVG in Android: 此代码示例显示Android中的SVG:
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
imageView.setImageDrawable(svg.createPictureDrawable());
The SVGParser functionality you mention is a third party implementation of SVG support for Android. 您提到的SVGParser功能是针对Android的SVG支持的第三方实现。
The major problems with using SVG in Android are: 在Android中使用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 我使用的所有第三方实现都有错误,无法正确加载或呈现一些SVG文件
Most of the third party implementations have been abandoned and none seem to be actively maintained 大多数第三方实施已被放弃,似乎没有一个被积极维护
I have written more about using SVG files in Android and the available third party libraries in the following article: 我在下面的文章中写了更多关于在Android中使用SVG文件和可用的第三方库的文章:
https://androidbycode.wordpress.com/2015/02/27/vector-graphics-in-android-part-1-svg/ https://androidbycode.wordpress.com/2015/02/27/vector-graphics-in-android-part-1-svg/
VectorDrawable supports of subset of SVG format that is designed to ensure it is fast to render. VectorDrawable支持SVG格式的子集,旨在确保快速呈现。 I have written about VectorDrawable and how to convert your existing SVG files to VectorDrawable here . 我已经写VectorDrawable以及如何转换现有的SVG文件VectorDrawable 这里 。
While android supports SVG 虽然android支持SVG
No, it does not, other than via WebView
or third-party SVG rendering libraries. 不,除了通过WebView
或第三方SVG渲染库之外,它没有。
Why we should convert SVG to VectorDrawble? 为什么要将SVG转换为VectorDrawble?
You are welcome to show SVG files via WebView
or third-party SVG rendering libraries. 欢迎您通过WebView
或第三方SVG渲染库显示SVG文件。 VectorDrawable
is an option; VectorDrawable
是一个选项; it is not a requirement. 这不是一个要求。
This code example shows svg in android: 这段代码示例显示了android中的svg:
There is no SVGParser
class in the Android SDK. Android SDK中没有SVGParser
类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.