AlertDialog自定义布局

dialog = new AlertDialog.Builder(context).create();
dialog.show();
//配置显示大小,居中
View inflate = LayoutInflater.from(context).inflate(R.layout.dialog_per_call, null);
dialog.setContentView(inflate);
Window window = dialog.getWindow();
window.setGravity(Gravity.CENTER);
WindowManager.LayoutParams params = window.getAttributes();
params.width= Util.getScreenWidth(context) *2/ 3;   //getResources().getDisplayMetrics().widthPixels

window.setAttributes(params);

TextView tvPhone = (TextView) inflate.findViewById(R.id.tv_dialog_per_phone);

猜你喜欢

转载自blog.csdn.net/dawan19909/article/details/78480735