Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android webview中更改html高度_Android_Html_Webview - Fatal编程技术网

在android webview中更改html高度

在android webview中更改html高度,android,html,webview,Android,Html,Webview,我有一个url,它在html正文中具有以下样式: style='width:468px; height:60px;' 我想在webview中添加url,但它的内容太大(witdh和height),所以我必须调整两者的大小。 我尝试了这些解决方案(,),但没有人为我工作。我使用以下方法更改了宽度: String javascript = "javascript:document.getElementsByTagName('div')[0].style.width='100%';"; vi

我有一个url,它在html正文中具有以下样式:

  style='width:468px; height:60px;'
我想在webview中添加url,但它的内容太大(witdh和height),所以我必须调整两者的大小。 我尝试了这些解决方案(,),但没有人为我工作。我使用以下方法更改了宽度:

 String javascript = "javascript:document.getElementsByTagName('div')[0].style.width='100%';";
 view.loadUrl(javascript);

但是它不适合高度,因为内容太大。您知道其他方法吗?

最后,我使用以下方法更改了尺寸:

    @Override
    public void onPageFinished(WebView view, String url) {
        float scale = myWebView.getHeight() / 170f;
        myWebView.setInitialScale((int) (scale * 100f));
        String js = "javascript:(function(){"
                + "document.getElementsByTagName('div')[0].style.height = 'auto';"
                + "document.getElementsByTagName('div')[0].style.width = 'auto';"
                + "})()";
        view.loadUrl(js);
    }