当前位置: 代码迷 >> Android >> android Dialog 阔是否占满
  详细解决方案

android Dialog 阔是否占满

热度:60   发布时间:2016-04-27 23:17:14.0
android Dialog 宽是否占满

WindowManager m = getWindowManager();  Display d = m.getDefaultDisplay();  //为获取屏幕宽、高  android.view.WindowManager.LayoutParams p = dialog.getWindow().getAttributes();  //获取对话框当前的参数值  p.height = (int) (d.getHeight() );   //高度设置为屏幕的p.width = (int) (d.getWidth());    //宽度设置为屏幕的dialog.getWindow().setAttributes(p);     //设置生效 
这样设置并没有作用。

InfoDialog infoDialog = new InfoDialog(context, R.style.ResultErrDialog);

WindowManager.LayoutParams lp = infoDialog.getWindow().getAttributes();
infoDialog.getWindow().setGravity(Gravity.BOTTOM);
Window win = infoDialog.getWindow();
win.getDecorView().setPadding(0, 0, 0, 0);

lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
win.setAttributes(lp);

infoDialog.show();

这样Dialog 跟屏幕一样的宽

版权声明:本文为博主原创文章,未经博主允许不得转载。

  相关解决方案