0

I am writing an view where I need to display superscript data. I am following this to achieve this.

Along this is there any way to change font size(in number) of superscript text.

EDIT Commanware suggested link work great, except one thing. I need superscript bit above of base text. I'm updating image for same, please refer. I'm using same code with mention in reference code.

enter image description here

Here either can go for separate text view could be second priority solution. Any suggestion !

Community
  • 1
  • 1
CoDe
  • 11,056
  • 14
  • 90
  • 197
  • 1
    Try other answers from that question, such as this one: http://stackoverflow.com/a/8872986/115145 – CommonsWare Apr 06 '15 at 12:45
  • I checked with available tag but I still need to make it look more small. – CoDe Apr 06 '15 at 13:02
  • 1
    The answer that I linked to did not use ``. – CommonsWare Apr 06 '15 at 13:07
  • @CommonsWare with other type face it giving bit issue. Super Script not showing top side of text, it come bit parallel of text. Any suggestion how can avoid such situation. – CoDe Apr 07 '15 at 06:09
  • Sorry, but I do not understand what you mean. I suggest that you open a separate Stack Overflow question, showing your current code, plus screenshots of what you are seeing that represents a problem. – CommonsWare Apr 07 '15 at 10:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/74633/discussion-between-shubh-and-commonsware). – CoDe Apr 07 '15 at 11:16

3 Answers3

3

try this one this is working code:

((TextView)findViewById(R.id.text)).setText(Html.fromHtml("04:30<sup><small>pm</small></sup>"));
Ravi Makvana
  • 2,872
  • 2
  • 24
  • 38
0

you cant pass text size in numbers, yo have to change the size to string :

<font size="3" color="red">This is some text!</font>
Akshay Paliwal
  • 3,718
  • 2
  • 39
  • 43
-1

Use this Code :

((TextView)findViewById(R.id.text)).setText(Html.fromHtml("your Text <sup style="font-size:5(yourfontsize);">subscript</sup>"));

Try this and Let me know :)

Anil Meenugu
  • 1,411
  • 1
  • 11
  • 16
  • I updated it bit...txtTime.setText(Html.fromHtml("your Text " + unit + " ")); but it's not reflecting anything new. – CoDe Apr 06 '15 at 13:16
  • Increase TextView Font Size and Check setText(Html.fromHtml("your Text subscript")); – Anil Meenugu Apr 06 '15 at 13:19
  • ((TextView)findViewById(R.id.text)).setText(Html.fromHtml("your Text subscript")); Make it 0 and check whether it is working not – Anil Meenugu Apr 06 '15 at 13:25
  • This is also not working, font size I'm using is 32sp for TextView. Checked with both above solution but not working. ;| – CoDe Apr 06 '15 at 13:32