Android Window Exit Transition未运行

时间:2018-12-14 21:06:08

标签: android android-transitions

我已经在styles.xml中定义了WindowEnterTransitionWindowReturnTransition
此外,我已经使用MainActivitygetWindow().setExitTransition()getWindow().setReenterTransition()中指定了窗口退出转换和窗口重新进入转换。过渡文件和相关过渡文件的代码如下:

styles.xml

<item name="android:windowContentTransitions">true</item>
<item name="android:windowReturnTransition">@transition/window_return</item>
<item name="android:windowEnterTransition">@transition/window_enter</item>

MainActivity

protected void onCreate(Bundle savedInstance) {

        //Set up exit and reenter transitions
        getWindow().setExitTransition(TransitionInflater.from(mContext).inflateTransition(R.transition.window_exit));
        getWindow().setReenterTransition(TransitionInflater.from(mContext).inflateTransition(R.transition.window_reenter));
}

window_enter.xml

<transitionSet
    xmlns:android="http://schemas.android.com/apk/res/android">
    <slide android:slideEdge="start"/>
</transitionSet>

window_return.xml

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <slide android:slideEdge="end"/>
</transitionSet>

window_exit.xml

<transitionSet android:duration="5000"
    xmlns:android="http://schemas.android.com/apk/res/android">
   <fade android:fadingMode="fade_out"/>
</transitionSet>

window_reenter.xml

<transitionSet android:duration="5000" xmlns:android="http://schemas.android.com/apk/res/android">
    <fade android:fadingMode="fade_in"/>
</transitionSet>

我从MainActivity开始活动B,如下所示:

startActivity(new Intent(MainActivity.this, DetailActivity.class), ActivityOptions.makeSceneTransitionAnimation(MainActivity.this).toBundle());

所有过渡均按预期工作。输入B时输入过渡,从B返回时返回过渡。重新输入MainActivity时重新输入转换(从B返回之后)。但是,似乎根本没有运行的过渡是退出过渡,我尝试在styles.xml和现在(如上所示)中都在onCreate中显式设置。为什么退出活动A(MainActivity)时不退出过渡运行?

0 个答案:

没有答案