Android 上的 SVG 支持 [英] SVG support on Android

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

问题描述

Android 是否支持 SVG?有什么例子吗?

Does Android support SVG? any example?

推荐答案

最完整的答案是这样的:

The most complete answer is this:

  • Android 2.x 默认浏览器本身不支持 SVG.
  • Android 3+ 的默认浏览器确实支持 SVG.

要将 SVG 支持添加到平台的 2.x 版本,您有两个基本选择:

To add SVG support to 2.x versions of the platform, you have two basic choices:

  1. 安装功能更强大的浏览器(如 Firefox 或 Opera Mobile - 均支持 SVG)
  2. 使用可以解析 SVG 并将其渲染到 HTML5 画布的 JavaScript polyfill

如果您只是想让 SVG 供个人使用或有限(可控)的用户组使用,则第一个选项是可以的.如果您想在面向庞大、不受控制的用户群的同时使用 SVG,这不是一个很好的选择.

The first option is okay if you're just trying to make SVG work for personal uses or a limited (controllable) set of users. It's not a great option if you want to use SVG while targeting a large, uncontrolled user base.

在后一种情况下,您想使用 polyfill.现在有许多 JavaScript 库可以使用 SVG 并渲染到画布上.两个例子是:

In the later case, you want to use a polyfill. There are many JavaScript libraries available today that can prase SVG and render to a canvas. Two examples are:

使用 polyfill,您可以在所有版本的 Android 2.x 上的 Canavs 中渲染您的 SVG.

Using a polyfill, you can render your SVG in a canavs on all versions of Android 2.x.

关于这种方法的更完整的例子,你可以参考这篇博文讨论了使用 canvg polyfill 制作 Kendo UI DataViz 图表(基于 SVG)在 Android 2.x 上工作.希望有帮助!

For a more complete example of this approach, you can refer to this blog post that discusses the use of the canvg polyfill for making Kendo UI DataViz charts (SVG-based) work on Android 2.x. Hope that helps!

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

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