全屏显示带有webview的AlertDialog

San*_*eep 2 android

在我的应用程序中,我在webview中加载了一个google docs url,并将该webview显示为Alert对话框的一部分.以下是我使用的代码:

            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);
Run Code Online (Sandbox Code Playgroud)

但我看到的是:

在此输入图像描述

任何想法,如何使对话框占据整个屏幕空间?

Rag*_*dan 5

您可以使用自定义对话框并将非对话框主题设置为相同的android.R.style.Theme或等android.R.style.Theme_Light.

 Dialog dialog=new Dialog(ActivityName.this,android.R.style.Theme);
Run Code Online (Sandbox Code Playgroud)

https://groups.google.com/forum/#!topic/android-developers/NDFo9pF8sHY