How to display fractions in android textview?

android, textview

Solution

You need to use HTML format to show fractions

tv.setText(Html.fromHtml("3<sup>1</sup>/<sub>2</sub>"));

Verify your HTML Text here.

As `Html.fromHtml(String s)` method has been depreciated. Take a look at this answer SO Answer

Problem

I want to display `3½` on android text view. I tried doing it with unicode but no luck. Please see my code below. Can anyone please help. ``` additionalInfoString = additionalInfoString.replace("½",<sup><small>&frac12;</small></sup>); ```

Original source

Related problems