Android 自定义dialog 设置宽度

	public static void showErrorCustomDialog(Activity activity, String title, String msg, String positivie, String result) {
		CustomErrorDialog.Builder builder = new CustomErrorDialog.Builder(activity);
		builder.setMessageType(0);
		builder.setMessage(msg);
		builder.setResult(result);
		builder.setTitle(title);

		builder.setPositiveButton(positivie, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				// 设置你的操作事项
			}
		});
		//builder.create().show();
		Dialog dialog = builder.create();

		dialog.show();
		//设置大小  
		DisplayMetrics dm = new DisplayMetrics();
		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
		dialog.getWindow().setLayout(dm.widthPixels, dialog.getWindow().getAttributes().height);

	}

你可能感兴趣的:(Android)