简体   繁体   English

Android活动过渡动画不一致

[英]Android activity transition animation inconsistent

In my one activity page, there are many item. 在我的一个活动页面中,有很多项目。 One of items, use startActivity() go to an android system settings activity, And its activity transition animation is slide_out_left. 其中一项,使用startActivity()转到android系统设置活动,其活动过渡动画为slide_out_left。

The other items use startActivity() go to my own activity. 其他项目使用startActivity()转到我自己的活动。 and activity transition animation is fade_out(defined in my style.xml). 活动过渡动画是fade_out(在我的style.xml中定义)。

I think that is a reason, but I don't know why? 我认为这是一个原因,但我不知道为什么? Why my style.xml changed all activity transition animation except one. 为什么我的style.xml更改了除一个以外的所有活动过渡动画。 or its there something I didn't notice? 还是有我没注意到的东西?

And how can I consistent all activity transition animation in XML file? 以及如何使XML文件中的所有活动过渡动画保持一致?

(I know overridePendingTransition() can change the animation, but I want to modify in .xml file, not in java code, to stay my java code easy readable in the future.) (我知道overridePendingTransition()可以更改动画,但是我想在.xml文件中而不是在Java代码中进行修改,以使我的Java代码在将来易于阅读。)

Please have a look at this answer and see whether it solves your issue or not: Start Activity with an animation 请查看此答案,并查看它是否可以解决您的问题: 使用动画启动“活动”

In short: 简而言之:

<style name="AppTheme">
    <item name="android:windowAnimationStyle">@style/MyAnimation</item>
</style>

<style name="MyAnimation" parent="android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/open_enter</item>
    <item name="android:activityOpenExitAnimation">@anim/open_exit</item>
    <item name="android:activityCloseEnterAnimation">@anim/close_enter</item>
    <item name="android:activityCloseExitAnimation">@anim/close_exit</item>
</style>

If you think this answers your question, please go to that original link that put in the answer and give the original author credit :) 如果您认为这可以回答您的问题,请转到答案中的原始链接,并给予原始作者以谢意:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM