【发布时间】:2016-05-18 23:20:49
【问题描述】:
这是对Animate ImageView from alpha 0 to 1 的跟进。
我有一个 ImageButton,我想在用户执行 X 时将其动画化到视图中,然后在用户执行 Y 时将其动画化到视图之外。动画 进入 视图工作正常。但是在视野之外制作动画是行不通的。事实上它正在工作,因为动画发生了。但是在按钮淡出视图后,它会以可见的形式弹回。所以我使用这个代码
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 保持不可见呢?
【问题讨论】:
-
看来我可能需要补充一点,ImageButton 中的图像本身就是一个动画 GIF。
标签: android android-layout animation alpha-transparency