How to use webview to open url just like UCBrowser

后端 未结 1 1009
萌比男神i
萌比男神i 2021-01-27 07:11

I am new in android. I am trying to make just a sample application to open websites in webview. The problem is, website opens in desktop mode. How can I open websites just like

1条回答
  •  旧时难觅i
    2021-01-27 07:57

    Try this. It should work.

    webview1.getSettings().setJavaScriptEnabled(true);
    webview1.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Toast.makeText(getApplicationContext(), description, Toast.LENGTH_SHORT).show();
            }
        });
        webview1.getSettings().setLoadWithOverviewMode(true);
        webview1.getSettings().setUseWideViewPort(true);
        webview1.getSettings().setBuiltInZoomControls(true);
        webview1 .loadUrl("http://www.matrixsystems.net.in/");  // set url
        webview1.requestFocus();
    

    0 讨论(0)
提交回复
热议问题