Search code examples
androidandroid-activityandroid-animationfade

How to animate fade out only on activity


I'm trying to perform fade out animation on activity but I only want to fade out and not fade in.
I saw this question: How to perform a fade animation on Activity transition? but it uses

overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

which also has fade in option that I don't want, I know I can make my own animation file and just leave it empty but it seems to my like not elegant solution. Is there anyway to ignore the fade in option in this function?


Solution

  • Yes, it's simple, the "id" for no animation is 0. So you can do the following:

    overridePendingTransition(0, android.R.anim.fade_out);