AnimationDrawable don't work in Android 2.2

前端 未结 2 829
迷失自我
迷失自我 2020-12-17 02:12

I using AnimationDrawable like this:

ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation);
rocketImage.setBackgroundResource(R.drawable.pr         


        
相关标签:
2条回答
  • 2020-12-17 02:49
    view.post(new Runnable() {
            public void run() {
                anim.start();
           }
        });
        view.startAnimation(anim);
    

    this works for me.

    0 讨论(0)
  • 2020-12-17 03:04

    As far as i know, thats a Bug in 2.1, 2.2

    A possible workaround could be:

    ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation);
    rocketImage.setBackgroundResource(R.drawable.progress_blue_animation);
    rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
    rocketImage.post(new Runnable(){
        public void run(){
            rocketAnimation.start();
        }
    });
    

    (But i didn't try it in Targets >2.1)

    0 讨论(0)
提交回复
热议问题