AchartEngine add text with superscript

2019-08-09 00:27发布

Is it possible to add superscript, or subscript characters to AchartEngine's x axes label, like you did in Microsoft Word?

1条回答
来,给爷笑一个
2楼-- · 2019-08-09 01:20

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.

查看更多
登录 后发表回答