I think I have found my own solution, which I put here for someone who needs it in the future. I just create one method to change the html chapter:
public static String changedHeaderHtml(String htmlText) { String head = "<head><meta name=\"viewport\" content=\"width=device-width, user-scalable=yes\" /></head>"; String closedTag = "</body></html>"; String changeFontHtml = head + htmlText + closedTag; return changeFontHtml; }
And I use it inside webview as follows:
public static void displayHtmlText(String htmlContent, String message, WebView webView, RelativeLayout videoLayout, LinearLayout standardLayout, LinearLayout webviewLayout){ WebSettings settings = webView.getSettings(); settings.setMinimumFontSize(18); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); webView.setWebChromeClient(new WebChromeClient()); String changeFontHtml = Util.changedHeaderHtml(htmlContent); webView.loadDataWithBaseURL(null, changeFontHtml, "text/html", "UTF-8", null); webviewLayout.setVisibility(View.VISIBLE); standardLayout.setVisibility(View.GONE); videoLayout.setVisibility(View.GONE); }
So, my content in a web browser is now suitable for the device and can display well.
source share