覆盖onAnimationEnd上的活动以结束并开始转换

时间:2013-10-23 17:25:07

标签: android animation transition

我正在尝试覆盖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) {

            }
        }); 

0 个答案:

没有答案