2

Subscript 2 is displayed correctly in all the following cases:

  • Directly pasting the utf-8 character

    <string name="subscript_two">₂</string>

  • Using the hex escape

    <string name="subscript_two">&#x2082;</string>

  • Using the decimal escape

    <string name="subscript_two">&#8322;</string>

But all the following cases display subscript 5 as regular 5.

  • Directly pasting the utf-8 character

    <string name="subscript_five">₅</string>

  • Using the hex escape

    <string name="subscript_five">&#x2085;</string>

  • Using the decimal escape

    <string name="subscript_five">&#8325;</string>

What's up with that?

It is rendered correctly in Android Studio's Layout Preview (on API 23), but not on my testing device that runs on CM 11, which is a fork of Kitkat 4.4.4 .

Now I know the Html.fromHtml() hack answered here, but I expect there's a cleaner way to make it happen in strings.xml itself - since subscript 2 works just fine.

I need it for putting P₂O₅ in EditText's hint and TextView, btw.

Community
  • 1
  • 1
Aditya Naique
  • 1,120
  • 13
  • 25

1 Answers1

1

Subscript 1 to 4 are inbuilt. They will always work. But to use subscript 5 to 9 you need to use html code inside your string <sub><small>5</small></sub> to get 5

Same applies for superscript <sup><small>5</small></sup> to get this 5

Peter Ola
  • 132
  • 8
  • Thanks, didn't know that only 1 to 4 are supported. I tried `5` but it doesn't work. I think it'll work if I set it in Java. I was hoping to do it in strings.xml itself. Anyway, thanks a bunch. :) Accepting your answer for the time being. Hope they add support for more unicodes in future. – Aditya Naique Sep 20 '15 at 11:51