Some help please!
How can i display raised numbers in a TextView for Android.For example if you want to display some Celsius degrees you can do this:textview.setText(number+"\u2103") and your good to go but i can't find a way to do something like this for number^anothernumber.
Thank you!
Format the string as HTML and then use the html superscript tag <sup>:
textView = (TextView)findViewById(R.id.textView);
String text = "x<sup>y</sup>";
textView.setText(Html.fromHtml(text));
Likewise if you want a subscript use the <sub> tag.
You can use simple html formatting:
String str = number + "<sup>" + anotherNumber + "</sup>";
textView.setText(Html.fromHtml(str), TextView.BufferType.SPANNABLE);
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