Reputation: 34530
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.
Upvotes: 4
Views: 899
Reputation: 184
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.
Upvotes: 1