0

I'm quite new to Android and I'm trying to display some chemical formulas in a textView which is contained in a customListView. I'm fetching all datas from xml parsing, then I wish to display the formula, such as C₉H₈O₄. But I can see only 1-4 digits.

I'm converting from "normal" to "subscript" in this way

str = str.replaceAll("0", "\u2080");
str = str.replaceAll("1", "\u2081");
str = str.replaceAll("2", "\u2082");
str = str.replaceAll("3", "\u2083");
str = str.replaceAll("4", "\u2084");
str = str.replaceAll("5", "\u2085");
str = str.replaceAll("6", "\u2086");
str = str.replaceAll("7", "\u2087");
str = str.replaceAll("8", "\u2088");
str = str.replaceAll("9", "\u2089");

str contains the formula fetched from the xml file.

The strange behavior is that I can see in the Logcat the formula as it should be.

I also tried with customs fonts but nothing.

Here are two results: the first is with normal font, the second with a custom one

https://www.dropbox.com/s/jyk64p700up14db/cella.jpg https://www.dropbox.com/s/ab9h1b45j2hrods/Schermata%2003-2456370%20alle%2022.05.45.png

Over the web I can read as a solution using something like

setText(Html.fromHtml("X<sub>2</sub>"));

but I really don't know how to use it in my case.

Any suggestion?

Enzoses
  • 115
  • 14

2 Answers2

0

It will not be easy trying to solv that problem with Html.fromHtml("X<sub>2</sub>") you need a lib that can help you to achieve that

(JEuclid is a complete MathML rendering solution, consisting of:) http://jeuclid.sourceforge.net/

Look at the example and you'll get a way to resolve your issue

Other alternatives for rendering math expressions with TeX:

http://jmathtex.sourceforge.net/
http://sourceforge.net/projects/snuggletex/
http://forge.scilab.org/index.php/p/jlatexmath/
Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65
0

Finally I solved the problem: It was a font issue. I just used Calibri and It works!

Enzoses
  • 115
  • 14