Вопрос

I am having trouble with webview wrapping my html incorrectly.

WebView webView = new WebView(getActivity());
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
webView.loadUrl(getArguments().getString(URL));

Ive set a border around body to see it, but webview leaves weird margin on the right, as if the text was scaled first and then the border was drawn, i dont know .. The stock browser however wraps it just fine

enter image description here enter image description here

I am not a web developer som please bear with me. I just presume its a webview issue as the stock browser renders it just fine.

Thanks!

Это было полезно?

Решение

Webview reflows text by default, so to not reflow it, set algorithm to

webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);

as in How to stop android webview content reflow when double tapped?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top