I am using the below code to render svg images to imageview in my android application
ImageView imageView = new ImageView(this);
final SVG svg = SVGParser.getSVGFromAsset(getAssets(), "start_4_480.svg");
imageView.setImageDrawable(svg.createPictureDrawable());
link : http://code.google.com/p/svg-android/wiki/Tutorial
Its working fine. But the size of an image is 2 MB(the same image is just few kbs in png format). I have lot of images of this kind. This increases the memory of my application.
So I want thought of using images in svgz formats(compressed svg). Can anyone tell me how to render svgz images directly to an image view in android. Please help. Also suggest me other ways of adapting images to different screen sizes and different file formats other than svn that makes this easy.
his is right. If you are distributing it as part of the APK, as it appears you are, it will be compressed anyway, so no need to compress it again.
If you want to loading it from a remote resource, you can wrap your InputStream in a GZIPInputStream before calling the parser.
public static SVG getSVGZFromInputStream(InputStream is) throws SVGParseException {
SVG svg = null;
try {
GZIPInputStream gis = new GZIPInputStream(is);
svg = SVGParser.getSVGFromInputStream(gis);
} catch (IOException e) {
//handle IO error
}
return svg;
}
To address your second question, before you abandon SVG for yet another file format, it is worth investigating if your SVG can be optimized to make it is a more acceptable size. For ideas on SVG optimization see the answer to this question If your SVG is still to big, the usual thing to do is fall back on multiple PNGs for each resolution.