下面是Dialog的style:
01.<!-- 全屏dialog样式 左右插入 -->
02. <style name="mydialog" parent="@android:style/Theme.Dialog">
03. <item name="android:windowFrame">@null</item>
04. <item name="android:windowIsFloating">true</item>
05. <item name="android:windowIsTranslucent">true</item>
06. <item name="android:windowNoTitle">true</item>
07. <item name="android:backgroundDimEnabled">false</item>
08. <item name="android:windowBackground">#FFFFFF</item>
09. </style>
下面是创建Dialog的代码:
01.Dialog dialog = new Dialog(Activity.this, R.style.mydialog);
02.dialog.setContentView(R.layout.layout);
03.LayoutParams lay = dialog.getWindow().getAttributes();
04.setParams(lay);
05.dialog.show();
下面是设置Dialog的LayoutParams的属性方法:
01.private void setParams(LayoutParams lay) {
02. DisplayMetrics dm = new DisplayMetrics();
03. getWindowManager().getDefaultDisplay().getMetrics(dm);
04. Rect rect = new Rect();
05. View view = getWindow().getDecorView();
06. view.getWindowVisibleDisplayFrame(rect);
07. lay.height = dm.heightPixels - rect.top;
08. lay.width = dm.widthPixels;
09. }