overridePendingTransition和FLAG_ACTIVITY_REORDER_TO_FRONT同时使用时,没有Activity启动动画
来源:互联网 发布:cae分析软件 编辑:程序博客网 时间:2024/06/07 05:49
转自: http://stackoverflow.com/questions/4633543/overridependingtransition-does-not-work-when-flag-activity-reorder-to-front-is-u
I have two activities in the stack, in order to show them I use FLAG_ACTIVITY_REORDER_TO_FRONT. So far so good, the problem comes when I want to bring the activity with an animation using overridePendingTransition.
Intent i = new Intent(ActivityA.this, ActivityB.class);i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); ActivityA.this.startActivity(i);overridePendingTransition(R.anim.transition_to_right, R.anim.transition_to_left);
The transition is not shown, however, if the flag is not added to the intent (removing line 2) then there is no problem.
Is it possible to bring an activity to front with an animation?
*******************解决方案一******************
I ran into this same problem. The trick is to override the transition in the onResume() callback.
@Overridepublic void onResume() { super.onResume(); overridePendingTransition(R.anim.transition_to_right, R.anim.transition_to_left);}
*******************解决方案二 ******************
Actually the right solution when using REORDER_TO_FRONT is to call overridePendingTransition in the method onNewIntent() of the activity you are going to open.
@Overrideprotected void onNewIntent(Intent intent) { super.onNewIntent(intent); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);}
replace with your transitions.
If you need to selectively replace the transition you can add an extra in your intent and check it in the onNewIntent() to decide what to do.
This is not suitable if you don't know the transition that will be opened (if you don't specify it explicitly for example) but otherwise is the right solution.
- overridePendingTransition和FLAG_ACTIVITY_REORDER_TO_FRONT同时使用时,没有Activity启动动画
- activity启动动画overridePendingTransition()使用
- Activity的启动模式:FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT
- Activity的启动模式:FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT
- Activity的启动模式:FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT
- Activity的启动模式:FLAG_ACTIVITY_CLEAR_TOP和FLAG_ACTIVITY_REORDER_TO_FRONT
- Activity 切换时的动画---overridePendingTransition简单使用
- Activity切换动画 之 overridePendingTransition()使用
- Activity切换动画overridePendingTransition的使用
- android activity切换动画使用overridePendingTransition
- Activity过渡动画(overridePendingtransition()的使用)
- activity切换时的overridePendingTransition动画效
- activity切换时的overridePendingTransition动画效
- activity切换时的overridePendingTransition动画效
- activity切换时的overridePendingTransition动画效
- activity切换时的overridePendingTransition动画效
- activity切换时的overridePendingTransition动画效果
- activity切换时的overridePendingTransition动画效果
- 谈谈head first系列
- vmprotect
- Apple Watch Human Interface Guidelines (Watch 人机交互指南) (官方文档翻译)
- 首届CCF计算机职业资格认证考试题解(C++)
- Tomcat中Java垃圾收集调优
- overridePendingTransition和FLAG_ACTIVITY_REORDER_TO_FRONT同时使用时,没有Activity启动动画
- 机器学习 第二周
- An universal algorithm design of fixed length substring locating
- ubuntu 14.04 更新 flash
- java中类与类之间,类与方法之间的调用程序
- jqueryui-example-autocomplete实现自动填充效果
- 安卓非绑定方式的service生命周期测试
- WIFI之服务器系统设计组成
- Linux IO模式及IO多路复用详解