1

I'm using a WebView to display a formatted HTML text file with color and font size.

My problem is it keeps removing spaces form the text, like it will combine two words together. I think it is because it is trying to fit the text within the screen width. How do I fix this? Or is there a better way to display formatted text like this? (I need size, color, links, and some centered text

This question has been already asked but was not answered. WebView removing spaces from text

Community
  • 1
  • 1
Vasanth
  • 6,257
  • 4
  • 26
  • 19

1 Answers1

1

I think you need load formatted local html file, so algorithm:

  • Parse you unformatted html data.

  • Format html data as you like, using .replace method

  • Load formatted data to your webview, like this: Load local html in WebView?
Community
  • 1
  • 1
artemiygrn
  • 1,036
  • 7
  • 18
  • This solution load HTML from a String variable. Worked for me String html = "Hello, World!"; String mime = "text/html"; String encoding = "utf-8"; WebView myWebView = (WebView)this.findViewById(R.id.myWebView); myWebView.getSettings().setJavaScriptEnabled(true); myWebView.loadDataWithBaseURL(null, html, mime, encoding, null); – Vasanth Jan 29 '14 at 11:28