I have create a dialog using AlertDialog
class. With custom view. I want to set entry and exit animation for it. when I try to do that dialog converts itself to small black background view. How to get animation with proper view ??
final AlertDialog.Builder builder = new AlertDialog.Builder(
/*getContext()*/
new android.support.v7.view.ContextThemeWrapper(getContext(), R.style.StyleDialog));
View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_email, null);
builder.setView(view);
builder.setCancelable(false);
alert = builder.create();
alert.show();
These are the styles
<style name="StyleDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/fadein</item>
<item name="android:windowExitAnimation">@anim/fadeout</item>
</style>
tried both android.support.v7.view.ContextThemeWrapper
and android.view.ContextThemeWrapper
but no difference.
Using android.app.AlertDialog
class.
I found the solution. Just set background(in my case white) for layout which I had not given. Because when we set our own style then it use black background by default and if do not set style then it uses white background by default.
android:background="@color/bg_white"
For proper width, set first view width to match_parent.
android:layout_width="match_parent"