SVG-的Andr​​oid ImageView的不工作 [英] svg-android imageview not working

查看:193
本文介绍了SVG-的Andr​​oid ImageView的不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要显示在我的Andr​​oid应用SVG文件。 SVG-的Andr​​oid 好像有任何文件的唯一库因此我的第一种方法。唯一可用的示例演示如何创建一个ImageView的附加SVG图像并将其连接到的主要内容视图。不过,我希望有一个SVG文件显示在我已经定义了一个RelativeLayout的。我试图像这样实现:

I have a need to show svg files in my android app. svg-android seems like the only library that has any documentation and thus my first approach. The only example available demonstrates how to create an imageview attach an svg image and attach it to the main content view. I however want a svg file to show up on a RelativeLayout I already have defined. I attempted an implementation like so:

ImageView imageView = new ImageView(this); 
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.logo); 
imageView.setImageDrawable(svg.createPictureDrawable());
RelativeLayout home_header = (RelativeLayout) findViewById(R.id.home_header);
home_header.addView(imageView);

所有出现良好(无警告/错误),但是当我测试应用程序日志猫报告:

All appears well (no warnings/errors) but when I test the app log cat reports:

05-27 11:25:43.940: I/Adreno200-EGLSUB(28492): <ConfigWindowMatch:2078>: Format RGBA_8888.
05-27 11:25:43.950: E/(28492): Can't open file for reading
05-27 11:25:43.960: E/(28492): Can't open file for reading

我已经验证了以下内容:
  - 文件是不是在任何其他程序中打开
  - 文件格式正确

I have verified the following: - File is not open in any other program - File is properly formatted

我缺少的是在这里吗?什么可能什么有什么建议?

What am I missing here? Any suggestions on what might be going on?

推荐答案

一些经过调试和仿真器比较原生应用程序,我发现,能读取无法打开文件是不相关的SVG文件不显示。相反,它是有关硬件加速。我不得不设置下在我的清单

After some debugging and comparing the emulator to the native app I discovered that the "can't open file for reading" is not related to the svg files not displaying. Instead it was related to hardware acceleration. I had to set the following in my manifest

android:hardwareAccelerated="false" 

问题解决了。浪费时间。脑熔断。

problem solved. Time wasted. Brain blown.

这篇关于SVG-的Andr​​oid ImageView的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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