2 回答

TA贡献1834条经验 获得超8个赞
使用监听器:
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimantionEnd(Animation animation) {
myProgressBar.setVisibility(View.GONE);
}
});

TA贡献1816条经验 获得超4个赞
尝试为动画对象设置一个动画监听器 (fadeOut):
myWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
myProgressBar.setProgress(newProgress);
if (newProgress == 100) {
AlphaAnimation fadeOut;
fadeOut = new AlphaAnimation(1, 0);
fadeOut.setDuration(500);
fadeOut.setFillAfter(true);
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// whatever you want to happen when the fadeOut animation starts
}
@Override
public void onAnimationEnd(Animation animation) {
// whatever you want to happen when the fadeOut animation ends
myProgressBar.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
// whatever you want to happen when the fadeOut animation repeats itself
}
});
myProgressBar.startAnimation(fadeOut);
} else {
myProgressBar.setVisibility(View.VISIBLE);
}
}
});
通过上面的回调,您可以挂钩AnimationStart,AnimationEnd和AnimationRepeat。
添加回答
举报