Android L过渡和主页按钮

Max*_*ine 0 android android-transitions shared-element-transition

我正在使用新的Android L转换,特别是共享元素转换以及Slide().当我按下后退按钮时,转换工作完美,它会将共享的ImageView滑动并转换到正确的位置,但是当我按下ActionBar中的home-up按钮时,它会忽略新的转换.

我在接收活动中设置了这段代码:

    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    getWindow().setExitTransition(new Slide());
    getWindow().setEnterTransition(new Slide());
Run Code Online (Sandbox Code Playgroud)

我的"主要"活动中的这段代码:

    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    Transition transition = new Slide();
    getWindow().setSharedElementEnterTransition(transition);
    getWindow().setSharedElementExitTransition(transition);
Run Code Online (Sandbox Code Playgroud)

Ale*_*ood 7

确保finishAfterTransition()在单击操作栏的向上按钮时调用:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finishAfterTransition();             
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)