美文网首页
2022-06-23

2022-06-23

作者: 霁逸lei | 来源:发表于2022-07-22 17:42 被阅读0次

    webView加载后计算网页高度、若有误可以让网页加接口传高度(测试本地网页高度需要计算,http远程网页不需要以下逻辑加载正常)
    setWebViewClient(new WebViewClient(){
    @Override
    public void onPageFinished(WebView view, String url) {
    final int measuredHeight = getMeasureContentHeight();
    //主线程更新UI
    post(new Runnable() {
    @Override
    public void run() {
    ViewGroup.LayoutParams params = getLayoutParams();
    params.height = measuredHeight;
    setLayoutParams(params);
    }
    });
    Log.d("CustomWebView", "measuredHeight:" + measuredHeight + ",getContentHeight" + getContentHeight() + ",getHeight" + getHeight() + ",getMeasureContentHeight" + getMeasuredHeight());
    super.onPageFinished(view, url);
    }
    });

    相关文章

      网友评论

          本文标题:2022-06-23

          本文链接:https://www.haomeiwen.com/subject/jxrmvrtx.html