philomath
philomath

Reputation: 2211

Android: limit rotate animation fps

I have an icon, and I want it to be rotate all the time. So far so good, only that I want to limit the frame to 12fps so that it will produce my expected effects. How can I do that?

   ImageView loadingCircle= (ImageView) getActivity().findViewById(R.id.loading_circle_image);    
   RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 1.0f * 360.0f,Animation.RELATIVE_TO_SELF,   0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(1000);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    rotateAnimation.setRepeatMode(Animation.INFINITE);
    loadingCircle.startAnimation(rotateAnimation);

Upvotes: 1

Views: 624

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

You can control duration but not number of frames generated. If that's needed, then you can make these 12 frames yourself using software like GIMP or Photoshop, and by rotating your image by hand to get 12 separate frames. Then you use Animation Drawable (docs here), create separate drawable XML for your animation and refer your separate frames from XML. Ensure you set android:duration for your frames correctly to have each of them shown per 12th part of second.

Upvotes: 1

Related Questions