svg手机怎么打开,android 加载外部矢量图SVG

 2023-09-23 阅读 21 评论 0

摘要:转自:http://blog.csdn.net/jiabailong/article/details/53736689 android加载矢量图的方式主要有以下两种: 一、Web方式 利用WebVIew来浏览SVG[html] view plain copy print?<html><embedsrc=“a.svg”width=“300”height=“300”type&#

转自:http://blog.csdn.net/jiabailong/article/details/53736689

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

一、Web方式

利用WebVIew来浏览SVG

[html] view plain copy
print?
  1. <html>  
  2.   
  3. <embed src=“a.svg” width=“300” height=“300” type=“image/svg+xml” />  
  4. </html>  
<html><embed src="a.svg" width="300" height="300" type="image/svg+xml" />
</html>
二、本地加载,使用ImageView来展示

[java] view plain copy
print?
  1. final URL url = new URL(“http://localhost:8080/commons/m.svg”);  
  2. HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();  
  3. InputStream inputStream = urlConnection.getInputStream();  
  4. SVG svg = SVGParser. getSVGFromInputStream(inputStream);  
  5. 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)

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/91399.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息