Home » Android » android – switching activities without animation

android – switching activities without animation

Posted by: admin March 10, 2020 Leave a comment


How can I use properly the Intent flag FLAG_ACTIVITY_NO_ANIMATION in AndroidManifest file? I supose my problem is trivial, but I can’t find good example or solution to it.

    <data android:name="android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION" />

However no error is reported by compliator, but data isn’t correct.
I just want to disable animation in case switching between activities. I can use getWindow().setWindowAnimations(0); in onCreate or onResume rather but using flag is better way, isn’t it?

I can use also in code:

Intent intent = new Intent(v.getContext(), newactivity.class);

But I want to use this flag in Android Manifest. To disable animation also in case returning from second activity to first.

How to&Answers:

You can create a style,

 <style name="noAnimTheme" parent="android:Theme">
   <item name="android:windowAnimationStyle">@null</item>

and set it as theme for your activity in the manifest:

   <activity android:name=".ui.ArticlesActivity" android:theme="@style/noAnimTheme">

You can also define a style to specify custom entry and exit animations.


If your context is an activity you can call overridePendingTransition:

Call immediately after one of the flavors of startActivity(Intent) or
finish to specify an explicit transition animation to perform next.

So, programmatically:

this.startActivity(new Intent(v.getContext(), newactivity.class));
this.overridePendingTransition(0, 0);


Try this code,

this.startActivity(new Intent(v.getContext(), newactivity.class).addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));


You can also just do this in all the activities that you dont want to transition from:

public void onPause() {
    overridePendingTransition(0, 0);

I like this approach because you do not have to mess with the style of your activity.


This is not an example use or an explanation of how to use FLAG_ACTIVITY_NO_ANIMATION, however it does answer how to disable the Activity switching animation, as asked in the question title:

Android, how to disable the 'wipe' effect when starting a new activity?


Here is a one-liner solution that works for as low as minSdkVersion 14 which you should insert in you res/styles.xml:

<item name="android:windowAnimationStyle">@null</item>

like so:

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowAnimationStyle">@null</item>



create your own style overriding android:Theme

<style name="noAnimationStyle" parent="android:Theme">
    <item name="android:windowAnimationStyle">@null</item>

Then use it in manifest like this:

<activity android:name=".MainActivity"


The line in the theme style works fine, yet that replaces the animation with a white screen. Especially on a slower phone – it is really annoying.
So, if you want an instant transition – you could use this in the theme style:

<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowDisablePreview">true</item>