popwindow
作者:
ae12 | 来源:发表于
2018-04-17 13:25 被阅读7次public void showDialog() {
dialog = new Dialog(this, R.style.BottomDialog);
inflate = LayoutInflater.from(this).inflate(R.layout.dialog_layout, null);
choosePhoto = (TextView) inflate.findViewById(R.id.choosePhoto);
takePhoto = (TextView) inflate.findViewById(R.id.takePhoto);
cancel = (TextView) inflate.findViewById(R.id.btn_cancel);
choosePhoto.setOnClickListener(this);
takePhoto.setOnClickListener(this);
cancel.setOnClickListener(this);
dialog.setContentView(inflate);
Window dialogWindow = dialog.getWindow();
dialogWindow.setGravity(Gravity.BOTTOM);
// WindowManager.LayoutParams lp = dialogWindow.getAttributes();
//获得window窗口的属性
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
//设置窗口宽度为充满全屏
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
//设置窗口高度为包裹内容
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
//将设置好的属性set回去
dialogWindow.setAttributes(lp);
//将自定义布局加载到dialog上
dialog.setContentView(inflate);
dialog.show();
}
本文标题:popwindow
本文链接:https://www.haomeiwen.com/subject/xaiukftx.html
网友评论