android 加载外部矢量图SVG
16lz
2021-01-25
转自:http://blog.csdn.net/jiabailong/article/details/53736689
android加载矢量图的方式主要有以下两种:
一、Web方式
利用WebVIew来浏览SVG
[html] view plain copy print ?- <html>
- <embed src=“a.svg” width=“300” height=“300” type=“image/svg+xml” />
- html>
二、本地加载,使用ImageView来展示 [java] view plain copy print ? - 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();
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)
更多相关文章
- GitHub 标星 2.5K+!教你通过玩游戏的方式学习 VIM!
- [置顶] Retrofit2使用方式和源码解析
- Java HTTP 网络请求库框架的使用
- android ndk build
- android wap连接网络设置代理
- android sdk manager 无法更新
- Android获取Contact Number的例子(2.0系统以前的获取方式)
- Android(安卓)Webview js或css 替换 注入
- MTK Android(安卓)平台开发之旅