1

I'm using Glide to load .png image asynchronously.

File file = Glide.with(context).load(location).downloadOnly(1024, 1024).get();

In case of .svg, the file is created but it is not loading into ImageView.

Sergey Emeliyanov
  • 5,158
  • 6
  • 29
  • 52
Papan
  • 382
  • 1
  • 10

1 Answers1

1

ImageView only accepts Bitmaps or VectorDrawables.

SVG is neither of the two, even if VectorDrawable descends from it.

Get a PictureDrawable from your SVG file. Then you need to create a Bitmap from the size of the PictureDrawable and give it to a Canvas.

PictureDrawable pictureDrawable = svg.createPictureDrawable();
Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(), pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888); 
Canvas canvas = new Canvas(bitmap); 
canvas.drawPicture(pictureDrawable.getPicture()); 
currentBitmap = bitmap;
milad salimi
  • 1,580
  • 2
  • 12
  • 31