gpt4 book ai didi

Android:方向更改后自定义动画丢失

转载 作者:行者123 更新时间:2023-11-29 01:30:36 26 4
gpt4 key购买 nike

我进行了大量研究,并尝试了所有我能想到的方法。

基本上,我有 3 个 Activity

Activity 1 -> Activity 2 -> Activity 3

我已经设置了 slide_left 和 slide_right 动画文件。基本上当用户点击进入 Activity 2 时——页面从右侧滑入。但是,当用户单击返回时(操作栏上的主页按钮)。它应该朝相反的方向滑动。

当它到达 Activity 3 并且用户旋转设备时,幻灯片动画的方向是错误的。 =( 这仅在用户旋转设备时发生。

onCreate()

// Override animation so that it animates as a slide in from left
overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out);

当用户旋转设备时,它就像失去了动画变化。

我发现了这个错误: https://code.google.com/p/android/issues/detail?id=25994

有人知道解决方法吗??处理此问题的最佳方法是什么?

最佳答案

我终于明白了!

在 onCreate() 方法中:

// Only run the animation if we are coming from the parent activity, not if 
// we are recreated automatically by the window manager (e.g. device rotation)
if (savedInstanceState == null) {
// Override animation so that it animates as a slide in from left
overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out);
}

我已经测试过了,效果很好。

引用:https://www.youtube.com/watch?v=CPxkoe2MraA

关于Android:方向更改后自定义动画丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31412797/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com