Ale*_* D. 5 iframe android webview
我想在 webView 中显示一些 html 内容。这是我的代码:
String htmlContent = "..."; // some content here
webViewContent.getSettings().setJavaScriptEnabled(true);
webViewContent.setWebViewClient(new WebViewClient());
webViewContent.setHorizontalScrollBarEnabled(false);
webViewContent.setHorizontalScrollBarEnabled(false);
webViewContent.getSettings().setSupportMultipleWindows(false);
webViewContent.getSettings().setAllowFileAccess(true);
webViewContent.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webViewContent.setWebChromeClient(new WebChromeClient());
webViewContent.setBackgroundColor(ContextCompat.getColor(context, R.color.background_final_page));
webViewContent.loadDataWithBaseURL(null, htmlContent , "text/html", "UTF-8", null);
Run Code Online (Sandbox Code Playgroud)
它可以很好地显示文本和图像,但是当我在 htmlContent 中有 iframe 时,例如
<iframe allowtransparency="true" frameborder="0" scrolling="no" src="https://www.facebook.com/plugins/post.php?href=link" width="100%"></iframe>
Run Code Online (Sandbox Code Playgroud)
webView 显示 iframe 不正确,高度被裁剪。当我将 height="100%" 添加到 iframe 代码时,它没有结果。当我设置 height=600 或 height=400 时,它可以工作,但我无法提前知道 iframe 的高度大小。那么,我该如何修复它呢?
| 归档时间: |
|
| 查看次数: |
1694 次 |
| 最近记录: |