Change Style of changing content View in Android Studio

I’d like to know if there is a way to change the style when a new content View is set.

In my app I have three different Activities and each of them has a different layout resource. When I’m switching between these Activities the belonging Layout get set with setContentView(). In the App, the switch between the Layouts looks like the new layout is sliding on top of the old from the left side (like slides changing in PowerPoint) . I don’t like these style so I’d like to change it. The best would be if the new layout appears immediately. Is there a way to do this ?

Answer

Starting from API level 5 you can call overridePendingTransition immediately to specify an explicit transition animation:

<set xmlns:android="http://schemas.android.com/apk/res/android" 
     android:fillAfter="true">
     <alpha android:fromAlpha="1.0" 
            android:toAlpha="0.0"
            android:duration="500"/> //Time in milliseconds
</set>

example:

startActivity();
overridePendingTransition(R.anim.hold, R.anim.fade_in);

or

finish();
overridePendingTransition(R.anim.hold, R.anim.fade_out);