-1

I spent many hours trying to find out why my Activities do not show any transition when calling Finish(). The default show/appear animation works as expected though.

I don´t want to override pending transitions with a custom animation. I just want the default transitions.

Update

I created a brand new project with a couple of regular activities and they transition-out as expected. Then I created 2 AppCompatActivity and added the support libraries to the project and voilá, same problem.

This is what my Theme looks like on values:

<style name="ChefTheme" parent="ChefTheme.Base">
</style>

<style name="ChefTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="colorPrimary">@color/primary</item>
  <item name="colorPrimaryDark">@color/primaryDark</item>
  <item name="colorAccent">@color/accent</item>
  <item name="android:windowBackground">@color/window_background</item>
</style>

and this is on values-v21:

<style name="ChefTheme" parent="ChefTheme.Base">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>
  <item name="android:windowContentTransitions">true</item>
  <item name="android:windowAllowEnterTransitionOverlap">true</item>
  <item name="android:windowAllowReturnTransitionOverlap">true</item>
  <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
  <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

Any idea why could this be happening?

xleon
  • 6,201
  • 3
  • 36
  • 52
  • 1
    Possible duplicate of [How can I add an animation to the activity finish()](http://stackoverflow.com/questions/4330675/how-can-i-add-an-animation-to-the-activity-finish) – Matt Clark Apr 11 '17 at 19:26
  • It´s not a duplicate as I don´t want to use overridePendingTransition. I just want the default transition to work – xleon Apr 11 '17 at 19:27
  • If you want it to animate, you have to add an animation. Don't expect Android/Android Studio to have one just set up for oyu – Zoe Apr 11 '17 at 19:28
  • 1
    Obviously whatever you are experiencing _is_ the default unless you have explicitly changed it. You will need to override it for anything else. – Matt Clark Apr 11 '17 at 19:29
  • All my Android apps do exit animations on Activities by default. It´s the fade out moving down – xleon Apr 11 '17 at 19:29
  • have you tried what @MattClark linked? – Derek Apr 11 '17 at 19:31
  • Yes, overriding pending transitions it works. But the point is that finishing activities should transition by default without any overriding. That´s why I think this is not a duplicate – xleon Apr 11 '17 at 19:34
  • **But** there was probably changes made somewhere that took away your default transition, maybe in your `manifest` file or `build.gradle` – Derek Apr 11 '17 at 19:37
  • Yes. I´ve trying to find out what kind of change I did for many hours. I reviewed all my code and I don´t see anything special. That´s why I asked here hoping that someone knew what the problem is. Downvotes seams that you don´t like my question though – xleon Apr 11 '17 at 19:42
  • Do you have a custom theme? – Derek Apr 11 '17 at 19:49
  • Yes, I updated the question – xleon Apr 11 '17 at 19:56

2 Answers2

1

It looks like you are applying your window to become translucent and you are testing on an API 21+ device.

Thus if you removed the following line:

<item name="android:windowIsTranslucent">true</item>

It should be back to normal. In fact, if you don't need to consume the material design specific APIs, there's no reason for a values-v21 folder. However including one will affect API 21+ devices by overriding the style.

The simplest fix here is to just make sure you know what you're including in that overridden style.

Jon Douglas
  • 13,006
  • 4
  • 38
  • 51
  • That was exactly the issue. Removing that line all transitions came back to normal. Sweet – xleon Apr 11 '17 at 21:51
1

Using finishAfterTransition() instead of finish() solved the issue for me. I think it is a cleaner solution than overriding the transition. Also it is the best option if you need a translucent window.

The Squake
  • 13
  • 3