android加载矢量图的方式主要有以下两种:

一、Web方式

利用WebVIew来浏览SVG

二、本地加载,使用ImageView来展示

final URL url = new URL("http://localhost:8080/commons/m.svg");

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

InputStream inputStream = urlConnection.getInputStream();

SVG svg = SVGParser. getSVGFromInputStream(inputStream);

Drawable drawable = svg.createPictureDrawable();

本地加载可以借助外部库利用glide(

https://github.com/bumptech/glide/tree/v3.6.0)

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐