Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 936
Mohit Deshpande Avatar asked Aug 22 '10 21:08

Mohit Deshpande


People also ask

How do you superscript on Whatsapp?

Just long press the no. You want as subscript and you will be shown the option automatically!

How do you superscript a string in Java?

To use superscript, you will have to fiddle with the Font of the displaying component. Checkout the API on Font. Show activity on this post. This can be done in java strings and some other cases also using Unicode Character super script...


1 Answers

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

or

Common Tasks and How to Do Them in Android

like image 176
Konstantin Burov Avatar answered Oct 03 '22 01:10

Konstantin Burov