【问题标题】:Android animations and screen rotationAndroid 动画和屏幕旋转
【发布时间】:2015-05-25 21:41:26
【问题描述】:

我使用 AnimatorSet 为一些属性设置了动画(简单的淡入、淡出等),但是当我更改屏幕旋转时,我的活动总是回到它的起始布局。我这里有什么遗漏吗?

ObjectAnimator fadeOut = ObjectAnimator.ofFloat(loginBtn, "alpha", 1f, 0f);
    fadeOut.setDuration(300);
    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(backBtn, "alpha", 0f, 1f);
    fadeIn.setDuration(300);
    final AnimatorSet mAnimationSet = new AnimatorSet();
    mAnimationSet.play(fadeOut).with(fadeIn);
    mAnimationSet.start();

【问题讨论】:

  • 什么意思?旋转屏幕时需要动画吗?
  • 我的意思是我想保持我之后的动画状态。当我转动我的设备时,布局会恢复到动画之前的状态。

标签: android android-animation


【解决方案1】:

在你的清单文件中使用这些代码(在你的活动类中),数据在移动设备的两种模式(横向或纵向)中都不会改变

android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|uiMod

或简单地使用这些

android:configChanges="orientation|screenSize|screenLayout"

【讨论】:

    猜你喜欢
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多