要解决Android CircularReveal bug(在同一个视图上启动另一种类型的动画后无法正常工作),您可以尝试以下解决方法:
ViewCompat.postOnAnimation(view, new Runnable() {
@Override
public void run() {
// 执行CircularReveal动画
Animator circularReveal = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
circularReveal.setDuration(duration);
circularReveal.start();
}
});
Animator circularReveal = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
circularReveal.setDuration(duration);
circularReveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
// 更新视图的可见性
view.setVisibility(View.VISIBLE);
}
});
circularReveal.start();
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// 移除监听器
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
// 执行CircularReveal动画
Animator circularReveal = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
circularReveal.setDuration(duration);
circularReveal.start();
}
});
请根据您的具体情况选择适合您的解决方法,并将相关代码集成到您的应用程序中。