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。
添加回答
舉報