Example usage for android.app AlertDialog onWindowAttributesChanged

List of usage examples for android.app AlertDialog onWindowAttributesChanged

Introduction

In this page you can find the example usage for android.app AlertDialog onWindowAttributesChanged.

Prototype

@Override
    public void onWindowAttributesChanged(WindowManager.LayoutParams params) 

Source Link

Usage

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;
}