0

I am using the new Android L transition, in particular shared element transitions along with a Slide(). When I press the back button the transitions work perfectly, it slides and transitions the shared ImageView to the correct spot but when I press the home-up button in the ActionBar it ignores the new transitions.

I set this block of code in the receiving activity:

    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    getWindow().setExitTransition(new Slide());
    getWindow().setEnterTransition(new Slide());

And this block of code in my 'Main' Activity:

    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    Transition transition = new Slide();
    getWindow().setSharedElementEnterTransition(transition);
    getWindow().setSharedElementExitTransition(transition);
Max Kleine
  • 143
  • 1
  • 1
  • 11

1 Answers1

7

Make sure you call finishAfterTransition() when the action bar's up button is clicked:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finishAfterTransition();             
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • Of course I call finish(). The problem still persists, it does not do the same animation. – Max Kleine Nov 29 '14 at 17:51
  • @MaxKleine Sorry, my original answer had a typo. I meant `finishAfterTransition()`, _not_ `finish()`. I've edited my post with the correction. – Alex Lockwood Nov 29 '14 at 19:50