我有一个可绘制对象(矢量(,我想让它像轮子一样旋转。我将如何解决这个问题?
这是我能找到的唯一与我的问题类似的问题,但问题是答案不适用于 VectorDrawables:在表面视图中对图像进行动画处理和旋转
我没有任何代码要显示,因为我什至不知道从哪里开始。我需要一些指导。
您可以将 VectorDrawable 转换为位图,然后使用来自链接的解决方案。
private Bitmap getBitmap(VectorDrawable vectorDrawable) {
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
vectorDrawable.draw(canvas);
return bitmap;
}