您的位置:首页 > 移动开发 > Android开发

android 位移动画移动后原地绑定的点击事件还在

2015-07-27 14:19 489 查看
今天为一个系统左侧的菜单栏设置了一个点击事件,设置了translateAnimation以后发现,当位移动画结束以后,菜单里边的button的onclick事件还在,不得不感慨这点官方做得实在够脑残,于是自己又加了一个控制view显隐的代码,最后代码是这样的:

private void startHideAnimation(){
if (isexpand==true) {
Animation hideAnimation = new TranslateAnimation(0, -menuLayoutWidth, 0, 0);
hideAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
hideAnimation.setDuration(800);
hideAnimation.setFillAfter(true);
hideAnimation.setAnimationListener(new 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
menuLayout.setVisibility(View.GONE);
}
});
menuLayout.startAnimation(hideAnimation);//直接设置的话,menulayout虽然从视野消失,但是原地点击的效果还在

}
isexpand = false;
}
private void startShowAnimation(){
if (isexpand==false) {
Animation showAnimation = new TranslateAnimation(-menuLayoutWidth, 0, 0, 0);
showAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
showAnimation.setDuration(500);
showAnimation.setFillAfter(true);

menuLayout.startAnimation(showAnimation);
menuLayout.setVisibility(View.VISIBLE);
}
isexpand = true;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: