【发布时间】:2015-10-16 04:45:32
【问题描述】:
为什么我使用一个动画后 mImageView.setVisibility 不起作用?
我的代码可以正常工作(CODE1)...
tbnVisible.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mImageView.setVisibility(View.VISIBLE);
} else {
mImageView.setVisibility(View.INVISIBLE);
}
}
});
任何时候我点击 ToggleButton (tbnVisible) 并且我的 CODE1 运行完美并且我的 ImageVies 出现和隐藏。之后,我运行 CODE2 以在同一个视图 (mImageView) 中运行一个淡入淡出的动画。
这是密码2...
btnAlphaAPI.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
mAlphaAnimation = mFadeOut ? fadeIn : fadeOut;
mAlphaAnimation.setDuration(2000);
mAlphaAnimation.setFillAfter(true);
mImageView.startAnimation(mAlphaAnimation);
mAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
mFadeOut = !mFadeOut;
}
});
}
});
这段代码也可以完美运行...直到知道,没关系,问题是当我再次尝试运行 de CODE1 时。当我单击 ToggleButton (tbnVisible) 时,我的 mImageView 不会发生更多情况。只是 CODE1 在运行 CODE2 后就不能正常工作了。
有人知道发生了什么吗?
非常感谢
【问题讨论】:
标签: android animation view visibility