Search code examples
javaandroidstringsuperscriptsubscript

Subscript and Superscript a String in Android


How can you print a string with a subscript or superscript? Can you do this without an external library? I want this to display in a TextView in Android.


Solution

  • ((TextView)findViewById(R.id.text)).setText(Html.fromHtml("X<sup>2</sup>"));
    

    or

    Common Tasks and How to Do Them in Android