全屏显示Dialog的设置

下面是Dialog的style:

<!-- 全屏dialog样式 左右插入 -->
    <style name="mydialog" parent="@android:style/Theme.Dialog">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:windowBackground">#FFFFFF</item>
    </style>


下面是创建Dialog的代码:

	Dialog dialog = new Dialog(Activity.this, R.style.mydialog);
	dialog.setContentView(R.layout.layout);
	LayoutParams lay = dialog.getWindow().getAttributes();
	setParams(lay);
	dialog.show();

下面是设置Dialog的LayoutParams的属性方法:

private void setParams(LayoutParams lay) {
  DisplayMetrics dm = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(dm);
  Rect rect = new Rect();
  View view = getWindow().getDecorView();
  view.getWindowVisibleDisplayFrame(rect);
  lay.height = dm.heightPixels - rect.top;
  lay.width = dm.widthPixels;
 }


 

你可能感兴趣的:(android,android,dialog,dialog)