protected Dialog getDialog(View view, float alaph, Context context) { /** * Builder的第二个参数是系统的style 或者 自定义的style,可以用来显示自己想要的风格,同时还可以避免黑框问题 */ AlertDialog.Builder builder = new AlertDialog.Builder(context,android.R.style.Theme_Material_Dialog_Alert); builder.setView(view); Dialog dialog = builder.create(); dialog.show(); Window window = dialog.getWindow(); // window.setContentView(view); WindowManager.LayoutParams lp = window.getAttributes(); lp.alpha = alaph; window.setAttributes(lp); window.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); return dialog; }