android 加载外部矢量图SVG

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

一、Web方式

利用WebVIew来浏览SVG

<html>

<embed src="a.svg" width="300" height="300" type="image/svg+xml" />
</html>

二、本地加载,使用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

posted @ 2016-12-19 11:16  清澈见底  阅读(804)  评论(0编辑  收藏  举报