AlphaAnimation 在 KitKat 中旋转帧布局



我有一个简单的活动,将箭头旋转到一个随机角度,当箭头停止旋转时,它会闪烁。闪烁效果是应用于箭头的照明版本的imageview的 alpha 动画。

它在Lollipop及以上工作正常,但在KitKat中,当应用 alpha 动画时,它会否定已完成旋转动画的setFillAfter,箭头立即变为笔直向上(0 度)

public void Spin2 ()
{
spinning = true;
degreeEnd = rnd.nextInt(360);
RotateAnimation spinIt = new RotateAnimation(0,3600+degreeEnd, RotateAnimation.RELATIVE_TO_SELF,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f);
spinIt.setDuration(6000);
spinIt.setFillAfter(true);
spinIt.setInterpolator(new DecelerateInterpolator());
spinIt.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
arrowLit.setVisibility(View.VISIBLE);
animBlink = new AlphaAnimation(1,0);
animBlink.setDuration(500);
animBlink.setInterpolator(new AccelerateInterpolator() );
animBlink.setRepeatCount(Animation.INFINITE);
// in KitKat this animation seems to reset the rotation..
arrowLit.startAnimation(animBlink);
spinning = false;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
theSpinner.startAnimation(spinIt);
}

有趣的是,当你再次开始旋转时,它会轻弹回它应该在的位置(degreeEnd)并从那里开始旋转。

就像它暂时覆盖了旋转的setFillAfter。 我已经在动画上尝试了setFillBefore等的各种组合。 此外,如果我将闪烁动画设置为有限数(例如 4),它将停止并保持在零 - 直到我重新旋转它才会纠正。

同样,这在 API 20 及更高版本中工作得很好。

感谢您的任何帮助

安 迪

这似乎与Frame Layout有关。一旦它不在等式中,它在 KitKat 上工作正常。

最新更新