0

我正在尝试为在开始和结束动画时使用的动画覆盖 onAnimationEnd 和 onAnimationStart。只是我不知道如何访问它们。我在哪里可以访问这些动画并覆盖这些方法?

下面显示了我的尝试。我觉得我很接近....但不完全在那里。

final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
           final Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);
           overridePendingTransition(R.anim.slide_in,  R.anim.slide_out);


           slideIn.setAnimationListener(new Animation.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) {
                // TODO Auto-generated method stub
                camera.startPreview();
                previewing = true;

                Camera.Parameters parameters = camera.getParameters();
                parameters.setPreviewSize(360, 480);

                camera.setParameters(parameters);

                LogUtils.log("onAnimationEnd");
            }
        });

        slideOut.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub
                 if(camera != null && previewing){
                     camera.stopPreview();
                     camera.release();
                     camera = null;

                     previewing = false;

                     LogUtils.log("onAnimationStart");
                  }
            }

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

            }

            @Override
            public void onAnimationEnd(Animation animation) {

            }
        }); 
4

0 回答 0