在我的应用程序中,我在 webview 中加载了一个 google docs url,并将该 webview 显示为警报对话框的一部分。以下是我正在使用的代码:
AlertDialog.Builder alert = new AlertDialog.Builder(
MockExamActivity.this);
alert.setTitle(R.string.writing_title);
WebView wv = new WebView(MockExamActivity.this);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("https://docs.google.com/file/d/string/edit?usp=sharing");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
view.loadUrl(url);
return true;
}
});
alert.setNegativeButton("Close",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
Dialog d = alert.setView(wv).create();
d.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
d.getWindow().setAttributes(lp);
但我看到的是:
任何想法,如何让对话框占据全屏空间?