-
Notifications
You must be signed in to change notification settings - Fork 0
android dialog
musejianglan edited this page Aug 8, 2016
·
1 revision
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog_layout);
dialog.setTitle("Custom Dialog");
//获得当前窗体
Window window = dialog.getWindow();
//重新设置
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
window .setGravity(Gravity.LEFT | Gravity.TOP);
lp.x = 100; // 新位置X坐标
lp.y = 100; // 新位置Y坐标
lp.width = 300; // 宽度
lp.height = 300; // 高度
lp.alpha = 0.7f; // 透明度
// dialog.onWindowAttributesChanged(lp);
//(当Window的Attributes改变时系统会调用此函数)
window .setAttributes(lp);
dialog.show();
progressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
Log.d("123", "dialog cancel");
hcd.setRead(false);
hcd2.setRead(false);
}
});
progressDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Log.d("123", "dialog dismiss");
}
});