我搜索了很多但没有得到答案......
这是我想要做的......
LayoutInflater inflater = (LayoutInflater)screen.getSystemService(screen.LAYOUT_INFLATER_SERVICE);
layout = inflater.inflate(R.layout.snap_log_viewer,null);
AlertDialog.Builder builder = new AlertDialog.Builder(SnapLog_Activity.this);
builder.setView(layout);
AlertDialog alertDialog = builder.create();
alertDialog.setCancelable(true);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = alertDialog.getWindow();
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
lp.copyFrom(window.getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
并且想在外面碰到时解雇...
尝试了
setBackgroundDrawable(new BitmapDrawable());
setOutsideTouchable(true);
但没有得到ouptput ..
答案 0 :(得分:1)
你不应该添加标志,并且在构建之后搞乱如何构建alertDialog。 怎么样尝试这一切:
AlertDialog alertDialog = new AlertDialog.Builder(**CURRENTACTIVITY**.this).create();
alertDialog.setTitle(getString(R.string.titleString));
alertDialog.setMessage(text);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dlg, int arg1)
{
dlg.dismiss();
}
});
alertDialog.setCancelable(true);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.show();
return;
}
});
答案 1 :(得分:0)
在显示之前将cancelable设置为true。
alertDialog.setCancelable(true);