更新时间:2022-12-30 20:58:32
我记得看到过这样的崩溃并阅读了有关 4.0.x 的错误,特别是在 AnimationListener (onAnimationEnd()) 中删除硬件层会导致这种崩溃.解决方案是将层转换发布为 Runnable.例如:
I remember seeing a crash like this and reading about a bug with 4.0.x in particular where removing a hardware layer in an AnimationListener (onAnimationEnd()) would cause this sort of crash. The solution was to post the layer transition as a Runnable. For example:
@Override
public void onAnimationEnd (Animation animation) {
//This will cause a crash
setLayerType(LAYER_TYPE_NONE, null);
}
@Override
public void onAnimationEnd (Animation animation) {
//This will work successfully
post(new Runnable() {
@Override
public void run () {
setLayerType(LAYER_TYPE_NONE, null);
}
}
}