0

EDIT: I've tried a WebView, which does render the HTML correctly, but it is also very slow, and has visual flicker when new data is loaded. I'm looking into what inside the WebView handles the HTML formatting, as it may be a little faster on its own...

I'm making a calculator. To make the input string look real pretty-like, I've been using the HTML.FromHTML() method to handle superscripts powers and subscripts for logs, to be displayed in textViews. For example, the following HTML is handled by your browser and probably looks correct (tested on Chrome and IE):

12+10log10(10log10(33))

The subscript 10s for the logs are properly positioned just slightly below their accompanying log text, and nesting does not cause a problem. Now, the HTML.FromHTML() as used in Android 4.0:

...fial

Definitely wrong. It appears that the <sub> tag, instead of implying a subscript of the wrapping text style, instead implies a vertical offset from the baseline. This meaning that having one <sup> tag will make the enclosed text offset by 1 constant amount from the baseline, two <sup> tags will cause two of these constant amounts from the baseline, etc. To make things worse, the <sub> tag merely subtracts this constant value. To add insult to injury, instead of the <small> tag scaling things in place, it also scales the offset of any text inside a <sup> or <sub> tag.

Is there any way I can make the HTML.FromHTML() method act in the same way as the text is rendered in web browsers? Assuming the answer to this is "not right now" or "you can write your own HTML parser!", does anyone have a suggestion to create similar functionality?

Thanks!

Vatsu1
  • 154
  • 2
  • 11
  • Did you tried using a different font ? – antoniom Sep 27 '12 at 06:22
  • @antoniom, how do you mean? Is there a HTML tag I can use to change the font? Or are you talking about using a different theme? – Vatsu1 Sep 27 '12 at 19:13
  • Droid Sans is the default font family for android webview. You can change the default font that webview uses. Look here: http://stackoverflow.com/questions/3900658/how-to-change-font-face-of-webview-in-android It may solve your problem – antoniom Sep 28 '12 at 06:41

0 Answers0