0

在我的android应用程序中,我需要一个接一个地为图像视图设置动画我有四个图像视图动画应该一个接一个地进行图像视图

我试过使用线程

            iv1=(ImageView)findViewById(R.id.imageView1);
    iv2=(ImageView)findViewById(R.id.imageView2);
    iv3=(ImageView)findViewById(R.id.imageView3);
    iv4=(ImageView)findViewById(R.id.imageView4);
    iv1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            animSlideUp = AnimationUtils.loadAnimation(getApplicationContext(),
                    R.anim.slide_up);
            mSplashThread1 =  new Thread(){
                @Override
                public void run(){
                    try {
                        synchronized(this){
                            // Wait given period of time or exit on touch
                            wait(5000);
                            iv3.startAnimation(animSlideUp);
                        }
                    } 
                    catch(InterruptedException ex){                 
                    }

                    finish();

                }
            };
            // The thread to wait for splash screen events
            mSplashThread =  new Thread(){
                @Override
                public void run(){
                    try {
                        synchronized(this){
                            // Wait given period of time or exit on touch
                            wait(5000);
                            iv2.startAnimation(animSlideUp);
                        }
                    } 
                    catch(InterruptedException ex){                 
                    }

                    finish();
                    mSplashThread1.start();             
                }
            };

            mSplashThread.start();
            // The thread to wait for splash screen events

我已经使用两个线程来启动动画请帮助我我是 android 新手

4

2 回答 2

2

You can use different values for

android:startOffset="100"

in animation xml file under res/anim folder for all four animations with the delay(in ms) value you want to use. In case you need help with how to use xml animations, here is a tutorial for your reference.

于 2013-08-28T16:58:47.500 回答
0

您可以使用AnimationListener。试试下面的代码:

       @Override
       public void onClick(View v) {

            animSlideUp = AnimationUtils.loadAnimation(getApplicationContext(),
                    R.anim.slide_up);

            animSlideUp.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                     animSlideUp.setAnimationListener(null);
                     iv3.startAnimation(animSlideUp);

                }
            });

            iv2.startAnimation(animSlideUp);

        }
于 2013-08-28T14:40:21.153 回答