【问题标题】:How get content Height in webview如何在 webview 中获取内容高度
【发布时间】:2017-10-18 00:36:37
【问题描述】:

我想获取 webView 的内容高度,我使用了webView.getHeight(),但它是 webview 的返回高度而不是内容高度。
这是我的代码:

webView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {

                Log.i("pageHeight", webView.getContentHeight()+"");
                webView.getViewTreeObserver().removeOnGlobalLayoutListener(this);

            }
        });

谁能帮帮我?

【问题讨论】:

    标签: android webview height


    【解决方案1】:

    您可以使用 JavaScript 进行设置,以下链接可能对您有所帮助。 https://capdroid.wordpress.com/2014/08/07/resizing-webview-to-match-the-content-size/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-23
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多