我在我的应用程序中使用android webview.我注意到它有内置边缘.所以需要根据UI要求删除它.
我用它来获得完美的结果.
@Override
public void onPageFinished(WebView view, String url) {
// super.onPageFinished(view, url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("javascript:document.body.style.margin=\"0%\"; void 0");
webView.setVisibility(View.VISIBLE);
}
当它被通知时它会被刷新,而且看起来太糟糕了.
但是我们可以将JavaScript应用到我们的HTML代码中吗?
我使用了< script> <脚本/>那边但没有结果.
webView.loadDataWithBaseURL(null, "<style>a{color:#3D7B8A; text-decoration:none}</style>"+ getDescription().replace("<p>", "<p style= \"line-height: 150%; text-align: justify;\" >"), "text/html", "utf-8",
null);
请指教.
解决方法:
据我所知,从上面的代码中,你没有填充= 0.
我看过谷歌,发现了这个问题和答案,你可能想看看:Remove unwanted White Space in WebView Android
By default webview has some margin/padding in body. If you want to remove that padding/margin then override body tag and add margin like:
<body style="margin: 0; padding: 0">