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