Showing AlertDialog with webview in full screen

In my app, I am loading a google docs url in webview and displaying that webview as part of a Alert dialog. Following is the code which I am using:

            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);

But what I see is:

enter image description here

Any idea, how can make the dialog take the full screen space?

Upvotes: 2

Views: 4702

Answers (1)

Raghunandan
Raghunandan

Reputation: 133560

You can use a custom dialog and set a non dialog theme to the same such as android.R.style.Theme or android.R.style.Theme_Light.

 Dialog dialog=new Dialog(ActivityName.this,android.R.style.Theme);

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

Upvotes: 5

Related Questions