Reputation: 17846
I use native Android Transition API to animate transition between activities. Here's the source I use to launch activity:
Intent intent = new Intent(MainActivity.this, DetailActivity.class);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this, imageView, imageView.getTransitionName()).toBundle();
MainActivity.this.startActivity(intent, bundle);
When I tap on hardware back button it returns to previous activity with expected reversed transition animation, but when I tap on "Up" button in Toolbar it returns to previous activity with default animation:
Upvotes: 1
Views: 1957
Reputation: 62189
Add following code to the activity, that is being finished:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
supportFinishAfterTransition();
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 5