4

This is how I open a dialog:

Dialog dialog = new Dialog(MainActivity.this);
dialog.setTitle("Animation Dialog");
dialog.getWindow().getAttributes().windowAnimations = R.style.AddDialogAnim;
dialog.show();

R.style.AddDialogAnim looks like this:

<style name="AddDialogAnim">
  <item name="android:windowEnterAnimation">@anim/slide_in</item>
  <item name="android:windowExitAnimation">@anim/slide_out</item>
</style>

On Android 2.2 (emulator), both enter and exit animations work fine.

On Android 4.2 (Galaxy Nexus) however, the dialog appears instantly and only the exit animation works.

I tried different things - using DialogFragment, different ways of setting the animations, etc.

fhucho
  • 34,062
  • 40
  • 136
  • 186
  • Its just so fast you cant see it maybe – Manoj Kumar Mar 28 '13 at 14:06
  • @Mojo If I set the animation to last 15 seconds, the dialog shows up instantly but its UI seems frozen for 15 seconds. – fhucho Mar 28 '13 at 14:32
  • Please post the `slide_in.xml` file too – Manoj Kumar Apr 01 '13 at 08:09
  • Check [this](http://developer.android.com/reference/android/provider/Settings.Global.html#ANIMATOR_DURATION_SCALE) out – Manoj Kumar Apr 05 '13 at 08:24
  • I don't have time to post the slide_in.xml, but I tried couple of different animations and all of them didn't work. The animation scale setting is set to default. – fhucho Apr 05 '13 at 17:06
  • @fhucho: I have EXACTLY the same problem with both ICS and JB! Did you solve yours? Does your Dialog has a webview? Please, take a look: http://stackoverflow.com/questions/17937663/dialog-animation-messed-up-by-webview-android-bug/18054590 – Luis A. Florit Aug 06 '13 at 19:18
  • @LuisA.Florit didn't solve this yet unfortunately. I'm not using a WebView. – fhucho Aug 06 '13 at 21:14
  • @fhucho: Funny that if you minimize the app while showing the dialog and maximize it again, the dialog entry animation is activated properly. Surely this is an android bug. Please post here a solution if you find one. – Luis A. Florit Aug 07 '13 at 13:32
  • @LuisA.Florit yes, looks like an Android bug... – fhucho Aug 07 '13 at 23:10

1 Answers1

1

Try to call your Dialog by below refer code:

  Dialog imageDiaglog= new Dialog(MainActivity.this,R.style.AddDialogAnim);

It will works fine in all version.

Vishnu
  • 184
  • 1
  • 7