android: webview inside dialog or popup

Here is example:

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("Title here");

WebView wv = new WebView(this);
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);

        return true;
    }
});

alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
        dialog.dismiss();
    }
});
alert.show();

You need to override setWebViewClient()..

mWebView = (WebView) view.findViewById(R.id.wv1);
mWebView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return false;
    }
});
mWebView.loadUrl(mUrl);

If you are trying to display a webview in a popup then you must set the width and height of your linear layout in your popup's layout file (popup_layout.xml) as shown below.

You have to do this because popup's layout doesn't have any parent to refer for the size when you try using 'match_parent' or so.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:layout_width="400dp"
android:layout_height="400dp"
android:background="#FAFAFA"
android:id="@+id/popup_layout"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<TextView
    android:id="@+id/txtclose"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_gravity="end"
    android:background="@color/colorPrimaryDark"
    android:text="X"
    android:textColor="@color/main_yellow"
    android:textStyle="bold" />

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/externalUrl"/>
</LinearLayout>