自定义一个Dialog,写完布局后运行,发现Dialog无法充满屏幕,就像下边这样:
代码大致如下:
Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_layout); Window dialogWindow = dialog.getWindow(); dialogWindow.setGravity(Gravity.BOTTOM); dialogWindow.getDecorView().setPadding(0, 0, 0, 0); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT