首页 > 代码库 > 全屏透明背景对话框

全屏透明背景对话框

透明背景对话框

        AlertDialog.Builder mBuilder = new AlertDialog.Builder(this, R.style.full_screen_dialog);
        View view = LayoutInflater.from(this).inflate(R.layout.item_list, null);
        mBuilder.setView(view);

        Dialog mDialog = mBuilder.create();
        Window win = mDialog.getWindow();
        //显示对话框时,后面的Activity不变暗。可选操作。

win.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); win.setWindowAnimations(R.style.anim_dialog_bottom); //获取对话框当前的參数值 WindowManager.LayoutParams params = win.getAttributes(); params.gravity = Gravity.BOTTOM; win.setAttributes(params); mDialog.show();

全屏风格:

  <style name="full_screen_dialog">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    </style>
<script type="text/javascript"> $(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘
    ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘
  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

全屏透明背景对话框