[英]Android Animation Bug wont let me click after animation move to the right
那么,这是我的问题吗? 我将其放置在滑出的位置,然后将其保持在该位置,然后您应该能够再次单击它,然后它将滑回到原始位置。
但是相反,我必须单击“ FIRST”所在的位置。 即使滑出。 我想在动画之后制作它,我可以在它滑出的任何位置单击它。
这是我的代码
public void sideBar()
{
ImageView sidebar = (ImageView)findViewById(R.id.sidebar);
if(out == 0)
{
mSlideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
mSlideInRight.setFillAfter(true);
sidebar.startAnimation(mSlideInRight);
out= 1;
}
else if(out == 1)
{
mSlideInLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
sidebar.startAnimation(mSlideInLeft);
out=0;
}
}
这是您单击它时的代码
public void onClick(View v) {
ImageView sidebar = (ImageView)findViewById(R.id.sidebar);
ImageView popup = (ImageView)findViewById(R.id.popup);
ImageView popup2 = (ImageView)findViewById(R.id.popup2);
switch(v.getId())
{
case R.id.sidebar:
sideBar();
break;
}
}
动画只会影响侧边栏ImageView
的绘制方式,而不影响其实际位置。 动画完成后,应将侧栏的布局参数更新到所需位置。 如果希望在动画运行时或动画完成后更新位置,或者希望在动画开始时发生位置更改,则在调用startAnimation
之后立即更新位置,可以在AnimationListener
执行此操作。
mSlideInRight.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation anim) {};
@Override
public void onAnimationRepeat(Animation anim) {};
@Override
public void onAnimationEnd(Animation anim) {
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(...);
// Set properties of layoutParams here
sidebar.setLayoutParams(layoutParams);
};
});
更换RelativeLayout
与任何布局您的ImageView是一个孩子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.