Android : WebView in Android doesn't display text properly

on Wednesday, March 25, 2015


I have a WebView which receives a string as content and it should display text, images and links normally. However, on Samsung Galaxy Note 4 (and 3, and maybe others), it warps the text so it's displayed all jumbled up, one word at a time.



mWebView =(WebView) view.findViewById(R.id.articletext);

mWebView.setPadding(0,0,0,0);
mWebView.setInitialScale(100);
mWebView.getSettings().setUseWideViewPort(false);

mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

mWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null);


htmlData here is a String containing the HTML of the data to be displayed.


On many other devices, this works perfectly, I even have functions to set up font sizes etc, but on Samsung Note 4 it doesn't. What should be a normal title and text ends up being one word in one row. I even tried removing the



mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);


but that's not the reason, apparently, as my emulator shows it is still jumbled up, on the left side of the screen.


What could be the reason for this? I've tried it on many devices, and only the Samsung devices (as far as I can tell) are giving me this problem. What can I do?


0 comments:

Post a Comment