3

嗨,我已使用以下代码进行内置放大缩小控制

   mWebView = (WebView) findViewById(R.id.webView1);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.getSettings().setSupportZoom(true);

我也使用了如下代码

    mWebView.setWebViewClient(new MyWebViewClient());
        mWebView.loadUrl(sabNZBurl);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        backwardBtn = (Button) findViewById(R.id.btnBackWard);
        cancelBtn = (Button) findViewById(R.id.btnCancel);
        refreshBtn = (Button) findViewById(R.id.btnRefresh);
        forwardBtn = (Button) findViewById(R.id.btnForward);

        backwardBtn.setOnClickListener(this);
        cancelBtn.setOnClickListener(this);
        refreshBtn.setOnClickListener(this);
        forwardBtn.setOnClickListener(this);

   final class MyWebViewClient extends WebViewClient {
    @Override
    // Show in WebView instead of Browser
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onLoadResource(WebView view, String url) {
        super.onLoadResource(view, url);

    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        PD.dismiss();
        view.getSettings().setBuiltInZoomControls(true);
        view.getSettings().setSupportZoom(true);
    }

}

但是 webview 仍然没有内置放大缩小控制,任何人都可以帮我解决这个问题

4

4 回答 4

3

您是否在网页中有要显示的视口元标记?如果是并且如果它包含user-scalable="no"则它是正常的,HTML 本身禁用缩放。只需像这样编辑标签:

<meta name="viewport" content="initial-scale=1.0, user-scalable=yes, width=device-width" />
于 2013-01-24T09:47:09.283 回答
3

试试这个,我有答案

WebSettings webSetting = mWebView.getSettings();
            webSetting.setBuiltInZoomControls(true);
于 2015-12-25T05:17:56.587 回答
2

可能这就是你正在寻找的..

settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
于 2014-09-30T07:55:47.637 回答
1

尝试这个:-

webview.getSettings().setUseWideViewPort(true);
于 2014-07-03T11:26:57.350 回答