0

I have an animationDrawable that has a list of frames (one by one) to display them as an animation.

The problem is that I want that drawable to be rotated 45 degree. Is there a way to rotate it before so the animation plays on a diagonal?

Thank you

Here is a XML animation

<animation-list android:id="@+id/selected" android:oneshot="false">
    <item android:drawable="@drawable/imag1" android:duration="150" />
    <item android:drawable="@drawable/imag2" android:duration="150" />
    <item android:drawable="@drawable/imag3" android:duration="150" />
 </animation-list>

and here is the code

ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);

//I want to rotate here

AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
frameAnimation.start();
Snake
  • 14,228
  • 27
  • 117
  • 250
  • See: http://stackoverflow.com/questions/4763103/rotating-a-drawable-in-android – dreamwagon Nov 20 '15 at 17:29
  • you want to rotate the drawable? use RotateDrawable ckass – pskink Nov 20 '15 at 17:32
  • Thanks for the link but it talks about bitmapdrawbale. See the code that I have above, how can I rotate that? – Snake Nov 20 '15 at 18:58
  • as i said, use RotateDrawable: http://codeshare.io/wz41j – pskink Nov 20 '15 at 20:08
  • @pskink, Thank you but my object is not of type rotatedrawable. It is AnimationDrawable. – Snake Nov 20 '15 at 20:15
  • what object? did you see my code? take a look into xml drawable i posted – pskink Nov 20 '15 at 22:10
  • Ohhhh I see, you had the animation list inside the rotate one. I guess I can accept it as an answer but I was hoping to rotate it in the code because I have over 40 xml that I really hate to change all of them – Snake Nov 21 '15 at 06:47
  • so see my link again – pskink Nov 21 '15 at 10:22
  • Excellllleeent! .Do you want to post it here so I accept it and others beneift from it – Snake Nov 23 '15 at 04:49
  • Also in addition since you have a lot of experience, can you check the last question I posted? I reaaaaaally hope you can help out with this as it is becoming a show stopper in my project :( – Snake Nov 23 '15 at 04:50

0 Answers0