As in the images shown below, is it possible to write code to write "to the power" in Android or Java?
Something like:
TextView t = (TextView) findViewById(R.id.text);
t.setText(Html.fromHtml("7<sup>2</sup>"));
According to Android documentation on their FAQ, you can always do this using a string resource, but if you do it on the fly you must make sure the TextView is using Spannable storage (always true if it's an EditText for example).
See Selecting, Highlighting, or Styling Portions of Text in the Android Common Tasks.
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