这是Animate ImageView from alpha 0 to 1的后续行动。
我有一个ImageButton,我希望在用户执行X时将其设置为视图,然后在用户执行Y时将动画设置为视图。将设置为视图正常工作正常。但是,在视野之外制作动画有点不起作用。事实上它是有效的,因为动画发生了。但是在按钮淡出视图后,它会弹回到VISIBLE状态。所以我使用这段代码
AlphaAnimation animation1 = new AlphaAnimation(0.9f, 0.0f);
animation1.setDuration(5000);
animation1.setStartOffset(1000);
animation1.setFillAfter(true);
animation1.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
GVLog.d(TAG,"MAKE INVISIBLE onAnimationStart: %s",tokenBtn.getVisibility());
}
@Override
public void onAnimationRepeat(Animation animation) {
GVLog.d(TAG,"MAKE INVISIBLE onAnimationRepeat: %s",tokenBtn.getVisibility());
}
@Override
public void onAnimationEnd(Animation animation) {
tokenBtn.setVisibility(View.INVISIBLE);
GVLog.d(TAG,"MAKE INVISIBLE onAnimationEnd: %s",tokenBtn.getVisibility());
}
});
tokenBtn.startAnimation(animation1);
但是使ImageButton不可见的调用没有生效。那么如何使它生效以使ImageButton保持不可见?
答案 0 :(得分:0)
试试这样。这些代码始终适用于我的应用。
AlphaAnimation animation1 = new AlphaAnimation(1, 0);
animation1.setDuration(1000);
tokenBtn.startAnimation(animation1);
tokenBtn.setVisibility(View.INVISIBLE);