hbDialog = new AlertDialog.Builder(this, R.style.Dialog_Fullscreen)
.setView(view).create();
hbDialog.setCanceledOnTouchOutside(true);
Window win = hbDialog.getWindow();
win.setGravity(Gravity.BOTTOM);
win.setWindowAnimations(R.style.dialog_anim);
win.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams lp = win.getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
win.setAttributes(lp);
对应的 style:
<style name="Dialog_Fullscreen" parent="@style/Theme.AppCompat.Dialog">
<!--<item name="android:windowFullscreen">false</item>-->
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
<!--<item name="android:windowCloseOnTouchOutside">true</item>-->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimAmount">0.8</item>
<!--//退出时的动画-->
</style>
<style name="dialog_anim">
<item name="@android:windowEnterAnimation">@anim/bottom_dialog_enter</item>
<!--//进入时的动画-->
<item name="@android:windowExitAnimation">@anim/bottom_dialog_out</item>
</style>
对应的 动画:
进入:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--%p指相对于父容器-->
<translate
android:duration="300"
android:fromYDelta="100%p" />
</set>
弹出:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:toYDelta="100%p" />
</set>