在 Android 应用程序中,我在 ImageButton
上实现 Animation
。动画结束后,按钮保留在最后一帧,但只能在初始位置单击,我通过主 .java Activity
BounceInterpolation
动画
TranslateAnimation translation;
translation = new TranslateAnimation(0f, 0F, 0f, 200);
translation.setStartOffset(150);
translation.setDuration(100);
translation.setFillAfter(true);
translation.setInterpolator(new BounceInterpolator());
mTourButton.startAnimation(translation);
我不知道如何更新ImageButton
参数。大多数解决方案都是针对 xml 实现的动画。我没有找到任何解决方案。我现在很累,请帮忙。
最佳答案
尝试使用onTouch()
来处理您的点击。
imageButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction())
{
case MotionEvent.ACTION_UP :
{
// Do whatever you want here.
}
return true;
}
});
应该可以了。
关于java - 实现动画后 ImageButton 不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31771134/