问题
Is it possible to add superscript, or subscript characters to AchartEngine's x axes label, like you did in Microsoft Word?
回答1:
You can try this
str = str.replaceAll("0", "⁰");
str = str.replaceAll("1", "¹");
str = str.replaceAll("2", "²");
str = str.replaceAll("3", "³");
str = str.replaceAll("4", "⁴");
str = str.replaceAll("5", "⁵");
str = str.replaceAll("6", "⁶");
str = str.replaceAll("7", "⁷");
str = str.replaceAll("8", "⁸");
str = str.replaceAll("9", "⁹");
String str = "X2";
String xtitle = str.replaceAll("2", "²");
renderer.setXTitle( xtitle);
Otherwise you can do
CharSequence xtitle = Html.fromHtml("X<sup>2</sup>");
But then you have to change achartengine library and change String to CharSequence because CharSequence cannot be cast to string.
来源:https://stackoverflow.com/questions/20441747/achartengine-add-text-with-superscript