我如何运行AnimationDrawable 3次

时间:2014-03-08 11:50:49

标签: android animation frame animationdrawable

大家好,再次感谢您的帮助。还要感谢你们给我这个帮助的任何帮助!

所以我有一个amimationDrawable一个coinSpinning。

    <animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:oneshot="true">
    <item android:drawable="@drawable/coinflip1" android:duration="25" />
    <item android:drawable="@drawable/coinflip2" android:duration="25" />
    <item android:drawable="@drawable/coinflip3" android:duration="25" />
    <item android:drawable="@drawable/coinflip4" android:duration="25" />
    <item android:drawable="@drawable/coinflip5" android:duration="25" />
    <item android:drawable="@drawable/coinflip6" android:duration="25" />
    <item android:drawable="@drawable/coinflip7" android:duration="25" />
    <item android:drawable="@drawable/coinflip8" android:duration="25" />
    <item android:drawable="@drawable/coinflip9" android:duration="25" />
    <item android:drawable="@drawable/coinflip10" android:duration="25" />
    <item android:drawable="@drawable/coinflip11" android:duration="25" />
    <item android:drawable="@drawable/coinflip12" android:duration="25" />
    </animation-list>

这是我在按钮onClick

后旋转硬币的方法
    public void spinCoin(){

        final ImageView coinAmina = (ImageView) findViewById(R.id.imageView1);
        coinAmina.setBackgroundResource(R.anim.coin_spin_heads); 
        coinAmina.post(new Runnable() {

            @Override
            public void run() {
                frameAnimation = (AnimationDrawable) coinAmina.getBackground();
                frameAnimation.start();
            }
        }); 

        //end of coin spin
        }

在onCreate之前我也有AnimationDrawable frameAnimation;

它运行正常,但我的问题一直试图运行它一定的时间,例如3 香港专业教育学院试图循环coinSpin()然后frameAnimation.stop,但没有好的

我还尝试使用Thread.sleep(500) setOneShot(false),然后在睡眠后更改为true

我想做的就是在我喜欢的任何时间运行动画。 另一个问题是,当我有2个硬币只旋转一个时,但这应该是另一个问题

我理解setOneshot(true)运行一次,false一遍又一遍地运行它......但我该怎么做呢

任何帮助都会受到很大关注

0 个答案:

没有答案