I'm struggling with this for hours now, sorry if this is a stupid question.
I want to open an AlertDialog (dimming the background) with an animation. The dialog view is a WebView. I tried two ways:
1) With a xml style AnimatedDialog:
<style name="AnimatedDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowAnimationStyle">@style/AnimatedDialogAnimation</item>
</style>
calling in the code
builder = new AlertDialog.Builder(context, R.style.AnimatedDialog);
The problem with this approach is that the dialog has an ugly frame, probably because the parent="@android:style/Theme.Dialog"
thing is wrong, but I couldn't find which is the correct one for an AlertDialog
. So I tried this:
2) Through a WindowManager.LayoutParams
:
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.windowAnimations = R.style.AnimatedDialog;
dialog.getWindow().setAttributes(lp);
The problem with this now is that the dialog is not animated (why??).
In addition, in both cases, the dialog 'flashes' briefly before shown, in other words, I can see it being 'build'. Maybe because of the WebView?
Can someone guide me how to do this properly?
Thanks!!