Android AlertDialog.Builder builder 自定义高宽

/**

*添加条码

*/

EditTextet_data;

Buttonbt_add;

ListViewlv_record;

TextViewtv_data;

private voidaddBarcode() {

LayoutInflater inflater = LayoutInflater.from(this);

@SuppressLint("InflateParams")

View v = inflater.inflate(R.layout.dialog_barcode_scanner, null);

et_data= (EditText) v.findViewById(R.id.et_data);

tv_data= (TextView) v.findViewById(R.id.tv_data);

bt_add= (Button) v.findViewById(R.id.bt_add);

lv_record= (ListView) v.findViewById(R.id.lv_record);

AlertDialog.Builder builder =newAlertDialog.Builder(this);

builder.setCancelable(false);

builder.setView(v);

finalAlertDialog dialog = builder.create();

dialog.show();

EditTextUtil.setEditText(this,et_data);

IS_DIALOG_SHOW=true;

DisplayMetrics dm =newDisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(dm);

Window window = dialog.getWindow();

assertwindow !=null;

WindowManager.LayoutParams params = window.getAttributes();

params.height= dm.widthPixels;

params.gravity= Gravity.CENTER_HORIZONTAL;

dialog.getWindow().setAttributes(params);

}

你可能感兴趣的:(Android AlertDialog.Builder builder 自定义高宽)