我为我的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);
}
答案 0 :(得分:0)
你可能会在它不起作用之前做一些不同的事情,你的问题不是很详细,所以我建议你使用你的应用程序,并尝试找到一个模式,当菜单不起作用,如果你看到一个某些事情导致它无法工作在代码中找到该部分并进行编辑。