Subscript and Superscript a String in Android

android, java, string, subscript, superscript

Solution

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

or

Common Tasks and How to Do Them in Android

Problem

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.

Original source

Related problems