Tuesday, 17 February 2015

loading svg images from server in android ?



Download  lib:  https://code.google.com/p/androidsvg/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount





add following code in your oncreate






relatvelayout = (RelativeLayout) findViewById(R.id.relatvelayout);
ImageView svgImageView = new ImageView(this);
relatvelayout.addView(svgImageView, new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
try{

   final URL urls = new URL("http://upload.wikimedia.org/wikipedia/commons/e/e8/Svg_example3.svg");
        HttpURLConnection urlConnection = (HttpURLConnection) urls.openConnection();
        InputStream inputStream = urlConnection.getInputStream();
        SVG svg = SVGParser. getSVGFromInputStream(inputStream);
        Drawable drawable = svg.createPictureDrawable();
        svgImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        svgImageView.setImageDrawable(drawable);

}catch(Exception e){

e.printStackTrace();
}

No comments:

Post a Comment