Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

svg-android imageview not working

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?

like image 953
Kevin Avatar asked Mar 18 '26 10:03

Kevin


1 Answers

android:hardwareAccelerated="false" will disable hardware rendering for the whole activity. An alternative might be to just use:

imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Which should disable it only for that View.

PS. If you are looking for an SVG library with better documentation (and more features), try mine: http://code.google.com/p/androidsvg/

like image 97
Paul LeBeau Avatar answered Mar 21 '26 14:03

Paul LeBeau