List of usage examples for android.app AlertDialog onWindowAttributesChanged
@Override public void onWindowAttributesChanged(WindowManager.LayoutParams params)
From source file:ab.util.AbDialogUtil.java
/** * AlertDialog ??//from w ww. ja va 2s .c om */ public static AlertDialog getAlertDialogWithoutRemove(Context mContext, int layout, double showWidth) { final AlertDialog alerDialog = new AlertDialog.Builder(mContext).create(); alerDialog.show(); alerDialog.setCanceledOnTouchOutside(true); Window window = alerDialog.getWindow(); // ?? int height = ScreenUtils.getScreenHeight(mContext); int width = ScreenUtils.getScreenWidth(mContext); WindowManager.LayoutParams params = window.getAttributes(); params.width = (int) (width * showWidth); params.gravity = Gravity.CENTER_HORIZONTAL; alerDialog.onWindowAttributesChanged(params); window.setContentView(layout); return alerDialog; }