我正在使用Glide
异步加载.png
图像。
File file = Glide.with(context).load(location).downloadOnly(1024, 1024).get();
[在.svg
的情况下,已创建文件,但未将其加载到ImageView
中。
ImageView仅接受位图或VectorDrawables。
SVG都不是两者,即使VectorDrawable从其降级。
从PictureDrawable
文件中获取SVG
。然后,您需要根据Bitmap
的大小创建一个PictureDrawable
,并将其赋予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;