0

我为我的 Activity 开发了 slideAnimation,但它有时不工作意味着动画盯着并结束并再次开始。即,动画完成但它又回到了以前的状态。但有时它工作得很好。

在此处输入图像描述 我正在使用以下代码:

class ClickListener implements OnClickListener {
        @Override
        public void onClick(View v) {
//         live=false;
//         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//         player.suspend();
//         player.resume();          

//            System.out.println("onClick " + new Date());
            SlideAnimationThenCallLayout me = SlideAnimationThenCallLayout.this;

            int w = app.getMeasuredWidth();
            int h = app.getMeasuredHeight();
            int left = (int) (app.getMeasuredWidth() * 0.65);

            if (!menuOut) {
             menucheck=true;
//             if(responed.equals("zero")){}
//             else
//             layout.setClickable(false);

                // anim = AnimationUtils.loadAnimation(context, R.anim.push_right_out_80);
                anim = new TranslateAnimation(0, left, 0, 0);
                menu.setVisibility(View.VISIBLE);
                animParams.init(left, 0, left + w, h);
            } else {
             menucheck=false;
//             layout.setClickable(true);

                // anim = AnimationUtils.loadAnimation(context, R.anim.push_left_in_80);
                anim = new TranslateAnimation(0, -left, 0, 0);
                animParams.init(0, 0, w, h);
            }

            anim.setDuration(500);
            anim.setAnimationListener(me);
            //Tell the animation to stay as it ended (we are going to set the app.layout first than remove this property)
            anim.setFillAfter(true);

            // Only use fillEnabled and fillAfter if we don't call layout ourselves.
            // We need to do the layout ourselves and not use fillEnabled and fillAfter because when the anim is finished
            // although the View appears to have moved, it is actually just a drawing effect and the View hasn't moved.
            // Therefore clicking on the screen where the button appears does not work, but clicking where the View *was* does
            // work.
            // anim.setFillEnabled(true);
            // anim.setFillAfter(true);

            app.startAnimation(anim);
        }
    }
    public void onAnimationEnd(Animation animation) {
        System.out.println("onAnimationEnd");
        ViewUtils.printView("menu", menu);
        Log.e("this is","onAnimaition end");
        ViewUtils.printView("app", app);
        menuOut = !menuOut;
        if (!menuOut) {
            menu.setVisibility(View.INVISIBLE);
        }
        layoutApp(menuOut);
    }
4

1 回答 1

0

你可能会在它不起作用之前做一些不同的事情,你的问题不是很详细,所以我建议你使用你的应用程序并尝试找到一个模式,当菜单不起作用时,如果你看到某件事是导致它不起作用在您的代码中找到该部分并进行编辑。

于 2013-07-29T20:33:52.193 回答