我有一个简单的活动,它将一个箭头旋转到一个随机的角度,当箭头停止旋转时,它会闪烁。闪烁效果是应用于发光版本箭头的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和更高版本中工作得很好。
谢谢你的帮助
安迪
发布于 2019-05-08 05:44:24
这似乎与Frame Layout有关。一旦它被排除在方程式之外,它就可以在KitKat上正常工作。
https://stackoverflow.com/questions/56027758
复制相似问题