AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.show(); Window window = alertDialog.getWindow(); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //setContentView (设置布局) window.setContentView(R.layout.dialog_modify); window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); WindowManager.LayoutParams lp = window.getAttributes(); lp.width = ViewGroup.LayoutParams.MATCH_PARENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; window.setAttributes(lp);