Java – Android: Remove all layout animations

Android: Remove all layout animations… here is a solution to the problem.

Android: Remove all layout animations

So I’m noticing that Android produces a slight fade between activities, which really annoys me, and I wonder if there is any way to get rid of it and let it “snap” to the next screen without animation at all?

I looked around but couldn’t find anything that really answered my question. I’m assuming it’s XML-based, but I see this person trying to do it programmatically here:
How do I eliminate the delay before an LayoutTransition animation, but what he did (applying a “blank” animation) didn’t seem to change anything.

Is there anything that can point me in the right direction? Tower!

Solution

The most elegant controls are implemented using styles and themes. This allows you to control it on a per-application and per-activity basis.

styles.xml (WhateverTheme is an Android theme that you implicitly or explicitly choose for your app):

<resources
    xmlns:android="http://schemas.android.com/apk/res/android" >

<style
        name="MyWhateverTheme"
        parent="@android:style/WhateverTheme">
        <item name="android:windowAnimationStyle">@style/MyActivityAnim</item>
    </style>

<style
        name="MyActivityAnim">
        <item name="android:windowEnterAnimation">@null</item>
        <item name="android:windowExitAnimation">@null</item>
    </style>
</resources>

Of course, you can also specify custom @animation this way.

In your Manifest.xml

:

    <application
        android:theme="@style/MyWhateverTheme" >

and change it for a specific activity:

        <activity
            android:theme="@style/SomeOtherTheme" >

Related Problems and Solutions