I recover chemical formula from a json file, and to write them in the good way (with number in subscript), I use this method:
String s = item.get(NAME);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '2' || s.charAt(i) == '3' || s.charAt(i) == '4'
|| s.charAt(i) == '5' || s.charAt(i) == '6') {
sb.append("<sub>").append(s.charAt(i)).append("</sub>");
} else {
sb.append(s.charAt(i));
}
}
name.setText(Html.fromHtml(sb.toString()));
It works fine but the font size of the subscript letters is the same than those of the others. And I'd like it is smaller. So is there a way to change the size of specific letters in a word ?
Thanks