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.
Just long press the no. You want as subscript and you will be shown the option automatically!
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...
((TextView)findViewById(R.id.text)).setText(Html.fromHtml("X<sup>2</sup>"));
or
Common Tasks and How to Do Them in Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With