How to write "power" and some text, as shown in Java or Android?

As in the images below, is it possible to write code for writing β€œfor food” in Android or Java?

enter image description here

enter image description here

+5
source share
2 answers

Sort of:

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

According to Android documentation about your frequently asked questions, you can always do this using a string resource, but if you do this on the fly, you need to make sure TextView uses Spannable storage (always true if it's EditText, for example).

See Selecting, highlighting, or styling parts of text in Android Common Tasks .

+7
source

HTML , - .

0

All Articles