Reputation: 1194
I am using android webview in my application.I noticed that it has the inbuilt margin.So need to remove it as per UI requirement.
I have used this it's getting the perfect result.
@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);
}
it's getting refreshed when it's notified and it's looks as too bad.
But we can apply the JavaScript to our html code as well right?
I have used <script> <script/>
over there but no result.
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);
Please advise.
Upvotes: 4
Views: 3097
Reputation: 637
As far as I'm aware, from the code above, you haven't made padding = 0
.
I have look on Google and found this question and answer, you may want to have a look: 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">
Upvotes: 3