Matjaž
Matjaž

Reputation: 2115

Superscript any character symbol code?

I was searching for x^y symbol code, with no luck. I am wondering if symbol code for superscript y (or any char form a-z) exist?

In this case:

<Button
    android:id="@+id/bPow"
    style="?android:attr/buttonStyleSmall"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="x^y" />

Upvotes: 1

Views: 832

Answers (3)

unitedartinc
unitedartinc

Reputation: 748

Try this,

Android textview supports HTML and you can easily put XY on a button

TextView txt=(TextView)findViewById(R.id.bPow);
txt.setText(Html.fromHtml("X<sup>Y</sup>"));

If you want to Adjust the Size of Font. According to android.text.Html (on GrepCode), you may use for smaller text, as only supports color and face attributes.

Try this

TextView txt=(TextView)findViewById(R.id.bPow);
txt.setText(Html.fromHtml("X<sup><small>Y</small></sup>"));

Else sometimes there is a chance to get the text cut out in some screens.

Likewise if you want a subscript use the "sub" tag. Thanks Have a nice day

Upvotes: 3

Vikram Singh
Vikram Singh

Reputation: 1420

try this, you can do it using this snippet:

yourWidget.setText(Html.fromHtml("X<sup>Y</sup>"));

Upvotes: 1

Wil Shipley
Wil Shipley

Reputation: 9543

No, but there are superscripted i and n:

1ⁱ 2ⁿ

Upvotes: 0

Related Questions