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:
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!