【问题标题】:Android Jelly Bean animations strange behaviorAndroid Jelly Bean 动画奇怪的行为
【发布时间】:2013-04-10 09:58:21
【问题描述】:

我正在为 ICS 及更高版本 (4.0+) 的 Android 版本开发应用程序。在我的应用程序中,我使用动画来为目标对象的属性设置动画(使用 ObjectAnimator),这是一个代码 sn-p:

    Animator disappearingAnimation = ObjectAnimator.ofFloat(regularScreenLayout, "alpha", 1f, 0f);

    AnimatorSet appearingAnimations = new AnimatorSet();
    Animator appearingAnimationAlpha = ObjectAnimator.ofFloat(statisticsScreenLayout, "alpha", 0f, 1f);
    Animator appearingAnimationTranslate = ObjectAnimator.ofFloat(statistics_wrapper, "y",
            changingContent.getHeight(), 0);
    appearingAnimations.playTogether(appearingAnimationTranslate, appearingAnimationAlpha);

    AnimatorSet animations = new AnimatorSet();
    animations.setDuration(ANIMATION_TIME);
    animations.playTogether(disappearingAnimation, appearingAnimations);
    animations.start();

我所有的动画在所有版本的 ICS 上都能完美运行,但在装有 Jelly Bean 的设备上它们开始表现得很奇怪。例如,如果我想通过消失的动画更改某些视图的可见性,则视图只会在没有动画的情况下出现/消失(动画不起作用!)。有人遇到过这种问题,或者知道可能是什么原因以及如何解决,我将不胜感激。分享你的经验。谢谢

【问题讨论】:

    标签: android animation android-4.2-jelly-bean


    【解决方案1】:

    尽管听起来很奇怪,但我通过结合视图和属性动画解决了这个问题(正如您在我的代码 sn-p 中看到的那样,我只使用了属性动画)。因此,更简单的动画,我使用视图动画(在 xml 中定义)来完成,而那些需要更改属性的动画,我使用新的属性动画来完成。这解决了我的问题,现在一切都在 ICS 和 Jelly Bean 设备上正常工作。希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2019-10-09
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 2016-05-25
      • 2013-02-14
      相关资源
      最近更新 更多