首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AlphaAnimation在KitKat中旋转Framelayout

问AlphaAnimation在KitKat中旋转Framelayout
EN

Stack Overflow用户
提问于 2019-05-08 01:30:57
回答 1查看 20关注 0票数 0

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

它在Lollipop和更高版本中工作得很好,但在KitKat中,当应用alpha动画时,它会否定已完成的旋转动画的setFillAfter,并且箭头会立即更改为垂直向上(0度)。

代码语言:javascript
复制
  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和更高版本中工作得很好。

谢谢你的帮助

安迪

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-08 05:44:24

这似乎与Frame Layout有关。一旦它被排除在方程式之外,它就可以在KitKat上正常工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56027758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档