I have an app where I'm doing activity transitions for a company directory. When a search result is selected, the animation of their photo to the detail screen works. And if I hit the back button, the reverse animation occurs. However, if I hit the back arrow from the Toolbar, the reverse animation never occurs.
The detail screen is a new DetailActivity with a single fragment in it called DetailFragment. I'm not doing anything special on "onBackPressed". Should I be?
If you want the return transition to play, you'll need to listen for the up-navigation button click and call finishAfterTransition()
directly:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finishAfterTransition();
return true;
}
return super.onOptionsItemSelected(item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With