开发者

Looping frame by frame animation

开发者 https://www.devze.com 2023-03-05 03:50 出处:网络
I\'m trying to get my animation to run only 6 times, I set the oneshot=\"true\" and tried to loop the animation but it doesn\'t work, the animation still runs only once.

I'm trying to get my animation to run only 6 times, I set the oneshot="true" and tried to loop the animation but it doesn't work, the animation still runs only once.

Any help is much appreciated.

Here is the code

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"  android:oneshot="true">
  <item android:drawable="@drawable/image" android:duration="100" />
  <item android:drawable="@drawable/image1" android:duration="100" />
  <item android:drawable="@drawable/image2" android:duration="100" />
  <item android:drawable="@drawable/image3" android:duration="100" />
  <item android:drawable="@drawable/image4" android:duration="100" />
 </animation-list>

.

    for (int i = 0; i < 5; i++){
        img.setBackgroundResource(R.anim.anime);
        AnimationDrawable frameAnimation = (AnimationDrawable)img.getBackground();
        frameAnim开发者_JAVA技巧ation.setCallback(img);
        frameAnimation.setVisible(true, true);
        frameAnimation.start();
   }


for (int i = 0; i < 5; i++){
    img.setBackgroundResource(R.anim.anime);
    AnimationDrawable frameAnimation = (AnimationDrawable)img.getBackground();
    frameAnimation.setCallback(img);
    frameAnimation.setVisible(true, true);
    frameAnimation.start();
}
frameAnimation.stop();
0

精彩评论

暂无评论...
验证码 换一张
取 消