How to remove inline marker in android web browser using javascript

I am using android webview in my application. I noticed that it has a built-in margin.So you need to remove it in accordance with the requirements of the user interface.

I used this to get 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 becomes updated when it is notified, and looks too bad. But can we also apply JavaScript to our html code? I used <script> <script/>there, but there was 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 inform.

+4
source share
1 answer

As far as I know, from the above code you did not padding = 0.

Google , : WebView Android

- / . /, margin, :

<body style="margin: 0; padding: 0">

+2

Source: https://habr.com/ru/post/1620299/


All Articles