0

I have a Drawable (Vector) and I want to animate it rotating like a wheel. How would I go about this problem?

This is the only question I could find similar to my problem but the issue is the answer doesn't apply to VectorDrawables: Animating and rotating an image in a Surface View

I don't have any code to show because I don't even know where to start. I need some guidance.

Sixteen
  • 29
  • 1
  • 7

1 Answers1

0

You can convert VectorDrawable to Bitmap and than use solution from link.

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;
}
esatr
  • 16
  • 1