使用FLAG_ACTIVITY_CLEAR_TOP活动之间的动画过渡 [英] Animation transition between activities using FLAG_ACTIVITY_CLEAR_TOP

查看:213
本文介绍了使用FLAG_ACTIVITY_CLEAR_TOP活动之间的动画过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我做了流行的所有活动,带来了第一个活动的方法。

In my android app, I'm making a method that pop all activities and bring up the first activity.

我用这个code:

Intent intent = new Intent(this, MMConnection.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.startActivity(intent);

正如我注意到,过渡仍是一个左到右的动画,没有人知道,如果在开始活动时,有一种方法来改变系统的动画?

As I noticed that the transition was still a left to right animation, does someone know if there is a way to change system animation when starting an activity?

其实,我最想要的有向左转移的权利(比如当被点击返回按钮)

Actually, I'd ideally like to have a right to left transition (like when the return button is tapped)

感谢您的帮助!

推荐答案

CoolMcGrr是正确的,你想用 overridePendingTransition(INT enterAnim,诠释exitAnim) 具体得到标准的后退按钮转型,我用这些作为 enterAnim exitAnim 转换:

CoolMcGrr is right, you want to use overridePendingTransition(int enterAnim, int exitAnim) To specifically get the standard "back button" transition, I use these as the enterAnim and exitAnim transitions:

push_right_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_shortAnimTime" />
</set>


push_right_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="@android:integer/config_shortAnimTime" />
</set>

这篇关于使用FLAG_ACTIVITY_CLEAR_TOP活动之间的动画过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆