How to write the “to the power” and some text like as shown in Java or Android?

前端 未结 2 1406
别那么骄傲
别那么骄傲 2021-01-03 00:45

As in the images shown below, is it possible to write code to write \"to the power\" in Android or Java?

\"enter

相关标签:
2条回答
  • 2021-01-03 01:25

    You can write HTML Code to show something like this.

    0 讨论(0)
  • 2021-01-03 01:31

    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.

    0 讨论(0)
提交回复
热议问题