Subscript and Superscript a String in Android

Mohit Deshpande picture Mohit Deshpande · Aug 22, 2010 · Viewed 82.3k times · Source

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.

Answer

Konstantin Burov picture Konstantin Burov · Aug 23, 2010
((TextView)findViewById(R.id.text)).setText(Html.fromHtml("X<sup>2</sup>"));

or

Common Tasks and How to Do Them in Android