0

同じ画面で異なるアニメーションが必要なため、アニメーションを作成するために 2 つのボイドを使用しています。そして、これはさまざまな ImageView のアニメーションです。この2つのImageViewを同時にメイン画面に追加すると。彼らは開始しますが遅れています。しかし、異なる ImageViews に同じアニメーションを使用しても問題はありません。この遅延が発生する理由は、スレッドを使用して呼び出します。わずか 2 つの ImageView とビットマップは非常に小さく、わずか 3 フレームです。

編集: EclipseからAndroid Studioにエクスポートされたプロジェクトでした。Androidスタジオで新しい空のプロジェクトを開き、すべてのコードとリソースを手動でコピーして貼り付けるだけで、問題なく動作します。

final RelativeLayout btt = (RelativeLayout) findViewById(R.id.bottomlinear); 

 class MyThread implements Runnable {

                          public MyThread() {
                              ImageView myImage3 ;
                              myImage3 = getimage( 0,btt.getHeight(),700);
                  startAnimation(myImage3);
                              btt.addView(myImage3);
                          }

                          public void run() {
                          }
                      }

                      Runnable r = new MyThread();
                      new Thread(r).start();

 class MyThread implements Runnable {

                          public MyThread() {
                              ImageView myImage4 ;
                              myImage4 = getimage( 0,btt.getHeight(),900);
                  startAnimation1(myImage4);
                              btt.addView(myImage4);
                          }

                          public void run() {
                          }
                      }

                      Runnable r = new MyThread();
                      new Thread(r).start();


     private void startAnimation(ImageView img)
        {

            AnimationDrawable mframeAnimation = null;
            BitmapDrawable  frame1 = (BitmapDrawable) getResources().getDrawable(R.drawable.aa);
            BitmapDrawable frame2 = (BitmapDrawable) getResources().getDrawable(R.drawable.bb);
            BitmapDrawable  frame3 = (BitmapDrawable) getResources().getDrawable(R.drawable.cc);


            // Get the background, which has been compiled to an AnimationDrawable object.
            int reasonableDuration = 10;
            mframeAnimation = new AnimationDrawable();
            mframeAnimation.setOneShot(false); // loop continuously
            mframeAnimation.addFrame(frame1, reasonableDuration);
            mframeAnimation.addFrame(frame2, reasonableDuration);
            mframeAnimation.addFrame(frame3, reasonableDuration);

            img.setBackground(mframeAnimation);

            mframeAnimation.setVisible(true,true);
            mframeAnimation.start();

        }
        private void startAnimation1(ImageView img)
        {
            AnimationDrawable mframeAnimation1 = null;
            BitmapDrawable  frame1a = (BitmapDrawable) getResources().getDrawable(R.drawable.d);
            BitmapDrawable frame2a = (BitmapDrawable) getResources().getDrawable(R.drawable.e);
            BitmapDrawable  frame3a = (BitmapDrawable) getResources().getDrawable(R.drawable.f);


            // Get the background, which has been compiled to an AnimationDrawable object.
            int reasonableDuration = 10;
            mframeAnimation1 = new AnimationDrawable();
            mframeAnimation1.setOneShot(false); // loop continuously
            mframeAnimation1.addFrame(frame1a, reasonableDuration);
            mframeAnimation1.addFrame(frame2a, reasonableDuration);
            mframeAnimation1.addFrame(frame3a, reasonableDuration);

            img.setBackground(mframeAnimation1);

            mframeAnimation1.setVisible(true,true);
            mframeAnimation1.start();

        }
4

0 に答える 0