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

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

问题描述

在我的 android 应用程序中,我正在制作一个弹出所有活动并调出第一个活动的方法.

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

我使用此代码:

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

当我注意到过渡仍然是从左到右的动画时,有人知道是否有办法在启动 Activity 时更改系统动画吗?

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, int exitAnim).

CoolMcGrr is right, you want to use overridePendingTransition(int enterAnim, int exitAnim).

为了专门获得标准的后退按钮"过渡,我将它们用作 enterAnimexitAnim 过渡:

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天全站免登陆