Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to stop animation between activity changes

I have multiple different Activity in my app and I don't want any transition animation when changing between Activities. Below is the how I'm changing between Activities:

Intent i = new Intent(FirstActivity.this, SecondActivity.class);             i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);             i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);             startActivity(i); 

This works great the first time I start a new Activity. There is no animation, but when I go back to an Activity that is already started it seems like the "Intent.FLAG_ACTIVITY_NO_ANIMATION" is ignored and the default animation happens.

I can't seem to figure out why this is happening.

like image 598
KevinM Avatar asked Apr 14 '11 23:04

KevinM


People also ask

How do I get rid of transitions on Android?

Open Settings . Scroll down and select Accessibility. Scroll down to Display and tap Text and display. Tap the toggle switch for Remove animations to turn it on.


2 Answers

Have you tried overridePendingTransition()?

like image 72
CommonsWare Avatar answered Sep 21 '22 14:09

CommonsWare


You can set FLAG_ACTIVITY_REORDER_TO_FRONT by code and FLAG_ACTIVITY_NO_ANIMATION in manifest as below:

Create noAnimTheme in res/values/styles.xml

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

or

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

and use it in manifest:

<activity android:name="SecondActivity" android:theme="@style/noAnimTheme"/> 

I hope it helps

like image 43
thanhbinh84 Avatar answered Sep 22 '22 14:09

thanhbinh84